Android:installlocation was introduced in Froyo (Android 2.2,api level:8). Setting this property allows developers and users to determine where the program will be installed.
The android:installlocation belongs to the manifest node in the Androidmanifest.xml. As shown below:
<manifestxmlns:Android="Http://schemas.android.com/apk/res/android"
Package="string"
android:Shareduserid="string"
android:Shareduserlabel="string Resource"
android:Versioncode="integer"
android:Versionname="string"
android: installlocation Span class= "pun" style= "margin:0px; padding:0px; line-height:1.5 ">= [" Auto " Span class= "PLN" style= "margin:0px; padding:0px; line-height:1.5 "> | "internalonly" | " >
. . .
</manifest>
Android:installlocation can be set to any of the three values of "auto", "internalonly", "preferexternal".
< span class= "tag" style= "margin:0px; padding:0px; line-height:1.5 "> Auto: program may be installed on external storage media ( For example: SD Card), but it will be installed to the phone memory by default. When the phone memory is empty, the program will be installed on the external storage media. When the program is installed on the phone, the user can decide to place the program in an external storage medium or in memory.
Internalonly:. When set to this value, The program can only be installed in memory, and if the memory is empty, the program will not install successfully.
Preferexternal: The program is installed on an external storage medium, but the system does not guarantee that the program will be installed on the external storage media. When external storage media is not available or empty, the program is installed in memory. The program uses the for The ward-locking mechanism will also be installed in memory because external storage does not support this mechanism. After the program is installed, the user can freely switch whether the program should be on external or internal storage media.
Note: When the program uses the Copy protection feature of Google Play, it can only be installed in memory.
When the program is installed on an external storage medium,
The ①.apk file will be moved to the external storage media, but the program's data will still be in memory
② the container where the. apk file is saved will be encrypted with a randomly generated key, so that only the settings for that program can use the data that exists on the external storage media.
Warning : When external storage media is unloaded, the program installed on the external storage media will be terminated immediately!
Backward compatibility:
Android:installlocation is declared, but Android:minsdkversion is less than 8 o'clock, we compile with an AVD of no less than Froyo, so android in a system below Froyo: InstallLocation will be ignored, and no less than fro Yo's system would use our designated android:installlocation.
We should not install the program on external storage media when our program has the following behavior
①service
The running service will be terminated and the service will not be restarted when the external storage media is reloaded.
②alarm Service
The alarm service will be canceled and the developer must re-register the alarm service after the external storage media is reloaded.
③input Method Engines
Input method will be replaced by the system input method, when the external storage media is reloaded, the user can use the system settings to start our input method
④live Wallpapers
Our live wallpaper will be replaced with the default live wallpaper. After the external storage media is overloaded, the user can change back.
⑤live Folders
Our dynamic folder will be moved out.
⑥app Widgets
Our widgets will be moved out, and our widgets are usually available only after the system restarts.
⑦account Managers
Accounts created with Accountmanager will disappear until the storage media is reloaded.
⑧sync Adapters
Our sync feature is only available when external storage media is reloaded
⑨device Administrators
Our deviceadminreceiver will be void.
⑩ Monitoring Boot End Event
Action_boot_completed broadcasts are sent before the external storage media is loaded. Therefore, programs installed on external storage media will not be able to accept power-on broadcasts.
In general, we can install our programs on external storage media as long as we do not use the above features. For example, a large game program. When our APK file is a few m large we should seriously consider whether to move the program to external storage media to help users save memory.
A brief analysis of Android:installlocation