Installing on the SD Card

Starting in Android 2.2, you can specify that your application may be installed on the SD card instead of on the phone's limited internal memory.

9. See http://d.android.com/guide/topics/resources/resources-i18n.html#best-match for a full explanation of how Android finds the best matching directory.

10. http://code.google.com/events/io/2010/sessions/casting-wide-net-android-devices.html

To do that, add the android:installLocation= attribute to the <manifest> tag in your AndroidManifest.xml file like this: <manifest ... android:installLocation="auto">

Valid values are auto and preferExternal. I recommend you use auto, which lets the system decide where it should go. Specifying preferExternal requests that your app be installed on the SD card but doesn't guarantee it. Either way, the user can move your application between internal and external storage with the Settings application.

The attribute will be quietly ignored on older versions of Android. If you leave it off entirely, Android will always put your program in internal storage.

So, why aren't SD card installs the default? It turns out that there are many situations where external installation is not a good idea. When you plug your phone's USB cable into your computer to charge it or share files, any running application installed on external storage will be killed. This is especially problematic for home screen widgets, which will simply vanish and never reappear.

Therefore, Google recommends11 that you do not allow external installation of applications that use any of the following features:

• Account managers

• Device administrators

• Input method engines

• Live wallpapers

• Sync adapters

As Android 2.2 adoption grows, users will expect everything to be installable on the SD card. If you choose not to allow it, be prepared to explain why to your users.

11. http://d.android.com/guide/appendix/install-location.html

Fast-Forward >> M 270

Supporting multiple versions of Android running on multiple hardware devices with multiple screen sizes is not easy. In this chapter, we've covered the most common issues and solutions to get you started. If you find yourself wanting more, I recommend reading the excellent best-practices document called "Supporting Multiple Screens" at the Android website.12

You've worked hard to get your application to this point. Now comes the fun part: letting other people use it. The next chapter will cover how to publish your app to the Android Market.

12. http://d.android.com/guide/practices/screens_support.html

0 0

Post a comment