Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發實例 >> Android 面試題積累

Android 面試題積累

編輯:Android開發實例

1、什麼是ANR 如何避免它?

http://www.fengfly.com/plus/view-193331-1.html

2、什麼情況會導致Force Close ?如何避免?能否捕獲導致其的異常?

3、Android本身的api並未聲明會拋出異常,則其在運行時有無可能拋出runtime異常,你遇到過嗎?諾有的話會導致什麼問題?如何解決?



4、簡要解釋一下activity、 intent 、intent filter、service、Broadcast、BroadcaseReceiver

http://www.fengfly.com/plus/view-193332-1.html


5、IntentService有何優點?

IntentService is a base class for Services that handle asynchronous requests (expressed as Intents) on demand. Clients send requests  through startService(Intent) calls; the service is started as needed, handles each Intent in turn using a worker thread, and stops itself  when it runs out of work.

This ‘work queue processor’ pattern is commonly used to offload tasks from an application’s main thread. The IntentService class exists to  simplify this pattern and take care of the mechanics. To use it, extend IntentService and implement onHandleIntent(Intent). IntentService  will receive the Intents, launch a worker thread, and stop the service as appropriate.

All requests are handled on a single worker thread — they may take as long as necessary (and will not block the application’s main loop), but  only one request will be processed at a time.”

IntentService 的好處

Acitivity的進程,當處理Intent的時候,會產生一個對應的Service

Android的進程處理器現在會盡可能的不kill掉你

非常容易使用

日歷中IntentService的應用

public class DismissAllAlarmsService extends IntentService {

@Override public void onHandleIntent(Intent unusedIntent) {

ContentResolver resolver = getContentResolver();

...

resolver.update(uri, values, selection, null);

}

}

in AlertReceiver extends BroadcastReceiver, onReceive():  (main thread)

    Intent intent = new Intent(context, DismissAllAlarmsService.class);

    context.startService(intent);

6.根據自己的理解描述下Android數字簽名

Android 數字簽名
       在Android系統中,所有安裝到系統的應用程序都必有一個數字證書,此數字證書用於標識應用程序的作者和在應用程序之間建立信任關系,如果一個permission的protectionLevel為signature,那麼就只有那些跟該permission所在的程序擁有同一個數字證書的應用程序才能取得該權限。Android使用Java的數字證書相關的機制來給apk加蓋數字證書,要理解android的數字證書,需要先了解以下數字證書的概念和java的數字證書機制。Android系統要求每一個安裝進系統的應用程序都是經過數字證書簽名的,數字證書的私鑰則保存在程序開發者的手中。Android將數字證書用來標識應用程序的作者和在應用程序之間建立信任關系,不是用來決定最終用戶可以安裝哪些應用程序。這個數字證書並不需要權威的數字證書簽名機構認證,它只是用來讓應用程序包自我認證的。
同一個開發者的多個程序盡可能使用同一個數字證書,這可以帶來以下好處。
(1)有利於程序升級,當新版程序和舊版程序的數字證書相同時,Android系統才會認為這兩個程序是同一個程序的不同版本。如果新版程序和舊版程序的數字證書不相同,則Android系統認為他們是不同的程序,並產生沖突,會要求新程序更改包名。
(2)有利於程序的模塊化設計和開發。Android系統允許擁有同一個數字簽名的程序運行在一個進程中,Android程序會將他們視為同一個程序。所以開發者可以將自己的程序分模塊開發,而用戶只需要在需要的時候下載適當的模塊。
(3)可以通過權限(permission)的方式在多個程序間共享數據和代碼。Android提供了基於數字證書的權限賦予機制,應用程序可以和其他的程序共享概功能或者數據給那那些與自己擁有相同數字證書的程序。如果某個權限(permission)的protectionLevel是signature,則這個權限就只能授予那些跟該權限所在的包擁有同一個數字證書的程序。
在簽名時,需要考慮數字證書的有效期:
(1)數字證書的有效期要包含程序的預計生命周期,一旦數字證書失效,持有改數字證書的程序將不能正常升級。
(2)如果多個程序使用同一個數字證書,則該數字證書的有效期要包含所有程序的預計生命周期。
(3)Android Market強制要求所有應用程序數字證書的有效期要持續到2033年10月22日以後。
Android數字證書包含以下幾個要點:
              (1)所有的應用程序都必須有數字證書,Android系統不會安裝一個沒有數字證書的應用程序
              (2)Android程序包使用的數字證書可以是自簽名的,不需要一個權威的數字證書機構簽名認證
              (3)如果要正式發布一個Android ,必須使用一個合適的私鑰生成的數字證書來給程序簽名,而不能使用adt插件或者ant工具生成的調試證書來發布。
              (4)數字證書都是有有效期的,Android只是在應用程序安裝的時候才會檢查證書的有效期。如果程序已經安裝在系統中,即使證書過期也不會影響程序的正常功能。

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved