Android APK application installation location selection and Widget impact

Source: Internet
Author: User
Tags home screen

Text from http://www.androidzz.com/2011/08/android-sd-app2sd/

 

Before Android 2.1, applications can only be installed in the body memory (RAM). This feature prevents Android development from some point of view, because RAM space is limited, this feature limits the size of the application and limits the functions of the application.

Since Android 2.2, the Android system has introduced an all-new feature, APP2SD, which allows the Android system to allow applications to be installed on the SD card, while saving more RAM space, on the other hand, applications are allowed to expand their size.

However, the Android system only supports APP2SD, which is not enough. If the application is not processed, it will continue to be transferred to RAM. This is because the Android system is backward compatible. What if I want my application to load an SD card instead of RAM? Therefore, you need to add the Android: installLocation attribute to the manifest element of manifest. xml in the app's android configuration file. The value is perferExtenal or auto.

PerferExtental -- it means that this application is installed to extended storage (usually the SD card), but the system cannot ensure that the application will certainly be installed to extended storage. If the extended storage has no space or is unavailable, the system will still install the application in RAM.

Auto -- it means that this application may be installed to the extended storage, but there is no particular preference for the installation location. There will be systems that decide where to install the application based on their own algorithms and many factors.

InternalOnly -- meaning that this application can only be installed in RAM.

 

Once android: installLocation is added, You can freely move the application between RAM and the SD card regardless of the value. After the application is installed on the SD card, pay attention to the following points:

1. Only the apk file is saved on the SD card. The private data, database, optimized dex file, and released native code of all other users are still stored in RAM.

2. the applications on the SD card are encrypted during installation. Therefore, the applications installed on the SD card only work on the devices where the application is installed and cannot run on other devices.

3. When you Enable USB high-capacity storage to share files with your computer or uninstall the SD card, all applications installed on the SD card will be immediately terminated.

 

Because the application installed on the SD card will be affected by the SD card status, to ensure the robustness of the application, when determining whether the application can be installed on the SD card, the following principles should be implemented:

1. Applications with backend services should not support APP2SD. Because the Service is invisible to the front-end interface, you cannot know whether the Service of the application is active when you detach the SD card or Enable USB. Therefore, the Service may be terminated unexpectedly.

2. The input method program should not support APP2SD. If SD is uninstalled or USB is enabled, the input method is terminated and replaced by the default input method.

3. Applications that normally display the UI, such as wallpapers and widgets, should not support APP2SD.

4. Applications related to user data, such as AccountManager, should not support APP2SD because users created through AccountManager cannot be seen before the SD card is mounted normally.

 

If the application has services, or supports desktop gadgets, do not install the software on the SD card. An insurance method is to specify the value of android: installLocation as internalOnly.

Because APP2SD is a new feature of Android 2.2, if the application is planned to support versions earlier than Android 2.2 for backward compatibility, perform the following steps:

1. Add the android: installLocation attribute to the manifest element and specify its value as perferExternal or auto.

2. specify the value of andorid: minSdkVersion. The value can be smaller than 8 (Before Version 2.2 ).

3. Change the build target of the application to API Level 8 so that the compiler can compile the application. (Required) If no build target is specified, the old Android library cannot understand the android: installLocation attribute and thus cannot compile the application.

 

After the preceding three steps are implemented, if the application is installed on a device with an API Level lower than 8, the android: installLocation attribute is ignored. The application is installed on RAM.

 

 

-------------------------- End of citation ---------------------------------------

 

Summary:

1. After Android 2.2 (API 8), manifest supports the android: installLocation attribute. The value range is internalOnly, perferExternal, and auto.

 

2. To be compatible with Android 2.1 and earlier versions, change the build target of the program to API Level 8, and change manifest's andorid: minSdkVersion to the original value. In this way, android devices under API 8 will be ignored

Android: installLocation property. devices over API 8 support the android: installLocation property.

 

3. if the app has widgets, after the widgets are installed on the SD card, the widgets will not be displayed in the widget list of the home screen. If the widgets are moved to the SD card, the displayed widgets will be deleted. If you want to keep widgets usable, you need to set the installation location of the application to android: installLocation = internalOnly.

 

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.