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

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。

更多相关文章

  1. 一款常用的 Squid 日志分析工具
  2. GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
  3. RHEL 6 下 DHCP+TFTP+FTP+PXE+Kickstart 实现无人值守安装
  4. Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
  5. 18 .Android中创建与几种解析xml的方法
  6. Android托管c++的log
  7. 从零编写一个一键生成mvp的android studio插件
  8. android 资源文件的使用说明
  9. Android(安卓)Studio中JNI程序的单步调试和日志打印

随机推荐

  1. Android Handler(六)
  2. Android 通过代码设置着色图片
  3. android 制作开机logo(bootanimation.zip
  4. Android生成与解析xml文件
  5. Share Android 8.0 network to Mac High
  6. Android ROM 相关资料
  7. Android完整的Fragment页面
  8. Android 数据库事务操作
  9. Android :实现一个手机卫士的一些要点
  10. Android httpclient接收xml乱码问题解决