Android App--Android apk默認安裝位置設置

在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卡,無法接收到開機廣播。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章