在Android工程中,設置apk的默認安裝位置
在AndroidManifest.xml文件Manifest標簽中添加android:installLocation屬性
android:installLocation
這個屬性設置的是默認安裝位置, 共有三個有效值,auto、internalOnly、preferExternal
對應表
auto 表示自動,由系統決定安裝位置
internalOnly 安裝在手機內存
preferExternal 安裝在外部存儲中
Constant | Value | Description |
auto | 0 | Let the system decide install location |
internalOnly | 1 | Explicitly request to be installed on internal phone storage only |
preferExternal | 2 | Perfer to be installed on SD card, There is no guarantee that the system will honor this request. The application might end up being installed on internal storage if external media is unavailable or too full |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ray" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
需要注意的問題(如果遇到其他問題,后期進行補充)
需要開啟啟動的程序,一定要安裝到手機內存中,這里就關系到廣播消息的先后順序
開機啟動的廣播消息BOOT_COMPLETE早於 SD的啟動,如果將程序安裝到SD卡,無法接收到開機廣播。
本文出自 Ray-Ray的博客
文章地址 http://www.cnblogs.com/rayray/p/3185811.html
感謝大家的推薦和收藏
你的支持! 我們的動力!