apk装到SD卡中

在Android2.2中新的特性可以支持类似APP2SD卡上,我们的APK文件可以安装在SD卡上供用户使用,Android123今天就说下目前项目的升级和一些配置。

1.首先让你的程序支持SD卡上安装必须具备设置APILevel至少为8,即androidmanifest.xml的中android:minSdkVersion至少为8这样你的APK最终运行时兼容的固件只有2.2了,同时在androidmanifest.xml文件的根节点中必须加入android:installLocation这个属性,类似代码如下:

<manifestxmlns:android="http://schemas.android.com/apk/res/android"

android:installLocation="preferExternal"

...>

2.android:installLocation的值主要有preferExternal、auto和internalOnly这三个选项,通常我们设置为preferExternal可以优先推荐应用安装到SD卡上,当然最终用户可以选择为内部的ROM存储上,如果外部存储已满,Android内部也会安装到内部存储上,auto将会根据存储空间自适应,当然还有一些应用可能会有特殊的目的,他们一般必须安装在内部存储才能可靠运行,设置为internalOnly比较合适,主要体现在:

Services服务

YourrunningServicewillbekilledandwillnotberestartedwhenexternalstorageisremounted.Youcan,however,registerfortheACTION_EXTERNAL_APPLICATIONS_AVAILABLEbroadcastIntent,whichwillnotifyyourapplicationwhenapplicationsinstalledonexternalstoragehavebecomeavailabletothesystemagain.Atwhichtime,youcanrestartyourService.Android123提示大家一般实时后台监控类的应用都应该装到内部存储,比较可靠。

AlarmServices闹铃提醒服务

YouralarmsregisteredwithAlarmManagerwillbecancelled.Youmustmanuallyre-registeranyalarmswhenexternalstorageisremounted.

InputMethodEngines输入法引擎

YourIMEwillbereplacedbythedefaultIME.Whenexternalstorageisremounted,theusercanopensystemsettingstoenableyourIMEagain.

LiveWallpapers活动壁纸

YourrunningLiveWallpaperwillbereplacedbythedefaultLiveWallpaper.Whenexternalstorageisremounted,theusercanselectyourLiveWallpaperagain.

LiveFolders活动文件夹

YourLiveFolderwillberemovedfromthehomescreen.Whenexternalstorageisremounted,theusercanaddyourLiveFoldertothehomescreenagain.

AppWidgetsWidget

YourAppWidgetwillberemovedfromthehomescreen.Whenexternalstorageisremounted,yourAppWidgetwillnotbeavailablefortheusertoselectuntilthesystemresetsthehomeapplication(usuallynotuntilasystemreboot).

AccountManagers账户管理

YouraccountscreatedwithAccountManagerwilldisappearuntilexternalstorageisremounted.

SyncAdapters同步适配器

YourAbstractThreadedSyncAdapterandallitssyncfunctionalitywillnotworkuntilexternalstorageisremounted.

DeviceAdministrators设备管理器

YourDeviceAdminReceiverandallitsadmincapabilitieswillbedisabled,whichcanhaveunforeseeableconsequencesforthedevicefunctionality,whichmaypersistafterexternalstorageisremounted.

那么哪些应用适合安装在SD卡中呢?Android开发网建议一些占用资源比较大的游戏,比如大于3MB的单个文件,不需要长期驻留内存的应用,不具备提醒和实时监控的应用一般放到SD卡上比较合适,不过目前想让你的应用装到SD卡上,必须设置APILevel至少为8以上,同时显示注明android:installLocation。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/raindrophust/archive/2011/04/28/6369810.aspx

相关推荐