Analysis of Android: installlocation

Source: Internet
Author: User

Android: installlocation is introduced in froyo (Android 2.2, API level: 8). By setting this attribute, developers and users can decideProgramInstallation location.

Android: installlocation is affiliated with the manifest node in androidmanifest. xml:

 <Manifest  Xmlns:  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=["Auto"|"Internalonly"|"Preferexternal"]>
...
</Manifest>
Android: installlocationCan be setAny of the three values "Auto", "internalonly", and "preferexternal.
 
Auto:The program may be installed on external storage media (for example, SD card), but it will be installed in the phone memory by default. when the phone memory is empty, the program will be installed on the external storage media. after the program is installed on the mobile phone, the user can decide to put the program outsideThe storage medium is still in memory.
 
Internalonly:Default Value. When this value is set, the program can only be installed in the memory. If the memory is empty, the program cannot be successfully installed.
Preferexternal:The program is installed on the external storage media, but the system does not guarantee that the program will be installed on the external storage media. when the external storage media cannot or is empty, the program will be installed in the memory. when the program uses the for ward-locking mechanism, it will also be installed into the memory, because external storage does not support this mechanism. after the program is installed, You can freely switch the program on the external or internal storage media.
 
Note:The copy protection feature of Google Play can only be installed in the memory.
 
When a program is installed on an external storage medium,
 
① The APK file will be moved to the external storage medium, but the program data will still be in the memory
 
② The container storing the .apk file will use a randomly generated key for encryption, so that only the settings for installing the program can use data stored on the external storage media.
Warning:When the external storage media is uninstalled, the program installed on the external storage media will be immediately terminated!
 
Backward compatibility:
 
When Android: installlocation is declared, but Android: minsdkversion is less than 8, we use AVD not lower than Froyo for compilation. In this way, Android: installlocation will be ignored in systems lower than froyo, the Android: installlocation specified by us will be used in systems not lower than fro yo.
 
When our program performs the following actions, we should not install the program on the external storage media.
 
① Service
 
The running service will be terminated. When the external storage media is reloaded, the service will not be restarted.
② Alarm service
 
The alarm service will be canceled. Developers must re-register the alarm service after the external storage media is reloaded.
 
③ Input Method Engines
 
The input method will be replaced with the system input method. After the external storage media is reloaded, you can start our input method through system settings.
 
④ Live wallpapers
 
Our live wallpaper will be replaced with the default live wallpaper. After the external storage medium is reloaded, you can change it back.
 
⑤ Live folders
Our dynamic folder will be removed.
 
⑥ App Widgets
 
Our widgets will be removed. Normally, our widgets are available only after the system is restarted.
 
7account managers
 
Accounts created using accountmanager will disappear until the storage media is reloaded.
 
⑧ Sync adapters
 
Our synchronization function is available only when the external storage media is reloaded.
 
Administrative device Administrators
Our deviceadminreceiver will be invalid.
 
Listen to boot end events
 
The system will send action_boot_completed broadcast before loading the external storage media. Therefore, programs installed in the external storage media cannot accept the boot broadcast.
 
Generally, as long as we do not use the above features, we can install our program on the external storage media. for example, a large game program. when the size of our APK file is several Mb, we should seriously consider whether to move the program to external storage media to help users save memory.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.