編輯:高級開發
在android 2.2中新的特性可以支持類似APP2SD卡上,我們的APK文件可以安裝在SD卡上供用戶使用,android123今天就說下目前項目的升級和一些配置。
1. 首先讓你的程序支持SD卡上安裝必須具備設置API Level至少為8,即androidmanifest.xml的中android:minSdkVersion至少為8這樣你的APK最終運行時兼容的固件只有2.2了,同時在androidmanifest.XML文件的根節點中必須加入android:installLocation這個屬性,類似代碼如下:
<manifest XMLns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
2. android:installLocation的值主要有preferExternal、auto和internalOnly這三個選項,通常我們設置為preferExternal可以優先推薦應用安裝到SD卡上,當然最終用戶可以選擇為內部的ROM存儲上,如果外部存儲已滿,android內部也會安裝到內部存儲上,auto將會根據存儲空間自適應,當然還有一些應用可能會有特殊的目的,他們一般必須安裝在內部存儲才能可靠運行,設置為internalOnly比較合適,主要體現在:
Services 服務
Your running Service will be killed and will not be restarted when external storage is remounted. You can, however, register for the ACTION_EXTERNAL_APPLICATIONS_AVAILABLE broadcast Intent, which will notify your application when applications installed on external storage have become available to the system again. At which time, you can restart your Service. android123提示大家一般實時後台監控類的應用都應該裝到內部存儲,比較可靠。
Alarm Services 鬧鈴提醒服務
Your alarms registered with AlarmManager will be cancelled. You must manually re-register any alarms when external storage is remounted.
Input Method Engines 輸入法引擎
Your IME will be replaced by the default IME. When external storage is remounted, the user can open system settings to enable your IME again.
Live Wallpapers 活動壁紙
Your running Live Wallpaper will be replaced by the default Live Wallpaper. When external storage is remounted, the user can select your Live Wallpaper again.
Live Folders 活動文件夾
Your Live Folder will be removed from the home screen. When external storage is remounted, the user can add your Live Folder to the home screen again.
App Widgets Widget
Your App Widget will be removed from the home screen. When external storage is remounted, your App Widget will not be available for the user to select until the system resets the home application (usually not until a system reboot).
Account Managers 賬戶管理
Your accounts created with AccountManager will disappear until external storage is remounted.
Sync Adapters 同步適配器
Your AbstractThreadedSyncAdapter and all its sync functionality will not work until external storage is remounted.
Device Administrators 設備管理器
Your DeviceAdminReceiver and all its admin capabilitIEs will be disabled, which can have unforeseeable consequences for the device functionality, which may persist after external storage is remounted.
那麼哪些應用適合安裝在SD卡中呢? android開發網建議一些占用資源比較大的游戲,比如大於3MB的單個文件,不需要長期駐留內存的應用,不具備提醒和實時監控的應用一般放到SD卡上比較合適,不過目前想讓你的應用裝到SD卡上,必須設置API Level至少為8以上,同時顯示注明android:installLocation。
對於android DEX文件進行優化,需要注意的一點是DEX文件的結構是緊湊的,但是我們還是要想方設法的進行提高程序的運行速度,我們就仍然需要對DEX文件進行進一步優
框架布局是將控件組織在android程序的用戶界面中最簡單的布局類型之一。理解布局對於良好的android程序設計來說是非常重要的。在這個教程裡,你將學到所有關於框架布
數據庫支持每個應用程序無論大小的生命線,除非你的應用程序只處理簡單的數據,那麼就需要一個數據庫系統存儲你的結構化數據,android使用SQLite數據庫,它是一個開源
國外一家名為Phandroid的網站近日披露了android 3.0(Gingerbread)的一些細節。雖然新的系統仍在開發之中,不過我們仍然可以從曝光的一些細節中看