A brief analysis of android:installLocation

In Froyo (android 2.2, API Level: 8), android:installLocation is introduced. By setting this attribute, developers and users can determine the installation location of the program.

android:installLocation belongs to the manifest node in AndroidManifest.XML. As shown below :

<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:installLocation can be set to any of the three values ​​"auto", "internalOnly", "preferExternal".
  auto: The program may be installed on an external storage medium (eg: SD Card), but it will be installed on the phone by default In memory. When the phone memory is empty, the program will be installed on the external storage medium. After the program is installed on the phone, the user can decide whether to put the program in the external storage medium or the internal memory.
  internalOnly: Default value. When set to When this value is set, the program can only be installed in the memory. If the memory is empty, the program will not be installed successfully.
  preferExternal: Install the program on the external storage medium, but the system does not guarantee that the program will be installed on the external storage medium. .When the external storage medium is unavailable or empty, the program will be installed into the memory. When the program uses the forward-locking mechanism, it will also be installed into the memory, because the external storage does not support this mechanism. After the program is installed, the user can Freely switch whether the program should be on the external or internal storage medium.
        Note: When the program uses the Copy Protection feature of Google Play, it can only be installed in the memory. When the program is installed on the external storage medium,
        ① .apk files will be moved to an external storage medium, but the program data will still be in memory
        ② The container that holds the .apk file will be encrypted with a randomly generated key, so that only the settings that install the program can use the data stored on the external storage medium .WARNING
        : When an external storage medium is unmounted, programs installed on the external storage medium will be terminated immediately!

Backwards Compatibility:
  Declare android:installLocation, but when android:minSdkVersion is less than 8, we use AVD not lower than Froyo to compile, so android:installLocation will be ignored in systems lower than Froyo, and will be used in systems not lower than Froyo We specify android:installLocation.
        When our program has the following behavior, we should not install the program to the external storage medium
  ①Service
    running services will be terminated, and the service will not be restarted when the external storage medium is reloaded.
  ②Alarm The Service
    alarm clock service will be cancelled, and the developer must re-register the alarm clock service after the external storage medium is reloaded.
  ③The Input Method Engines
    input method will be replaced with the system input method. When the external storage medium is reloaded, the user can start it through the system settings Our input method
  ④Live Wallpapers
    Our live wallpaper will be replaced with the default live wallpaper. After the external storage medium is reloaded, the user can change it back.
  ⑤Live Folders
    Our live folder will be moved out.
  ⑥App Widgets
    Our widgets will be replaced by Removed , usually our widgets are only available after a system restart.
  ⑦Account Managers
    Accounts created with AccountManager will disappear until the storage medium is reloaded.
  ⑧Sync Adapters
    Our sync function is only available when the external         storage     medium     is
  reloaded Accept the boot broadcast.         Usually, as long as we do not use the above features, we can install our programs to external storage media. For example, large game programs. When our APK file is several megabytes in size, we should seriously consider Whether to move the program to an external storage medium to help the user save memory.






Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326573256&siteId=291194637