Supporting multiple phones and screensizes in your android applications
When releasing an android application it is often desirable to release your application to the largest amount of users as possible. By developing an application with android 1.5 as the target, later versions are automatically supported (1.6, 2.0, and 2.1). However different screen-sizes were introduced with android 1.6 so by default an application will not support smaller screens (larger screens are automatically supported).
Android Versions Marketshare
The image below shows the current market share for the different version of android:
|Android Platform||Percentage of Devices|
Devices with small screens include the following phones T-Mobile G1, Samsung I7500, and the HTC Tattoo. Unfortunately I cannot find any statistics regarding the percentage of small screen android users (if you can please let me know). However as the fix is very simple it seems stupid not to.
To add support for different screen sizes we need to add a supports-screens tag in our android_manifest.xml. This should look like the following:
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="false" />
This tells android that the application should work on large, normal and small screens. Note that only setting small to false will prevent it from been visible in the market to small screened phones, for normal and large it will simply change the method of which android interprets the display of this application. anyDensity fix me
However in order to use the supports-screens tag the target of your application must be android 1.6 (or Sdk version 4). We can allow our program which is now targetted for android 1.6 still be avaliable for android 1.5 (Sdk version 3) by adding android:minSdkVersion=”3″ to our uses-sdk tag.
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
Now your application can be built for 1.6 supporting smaller screen sizes and still work on 1.5.
Below are screenshots from two AVD’s, one with a normal screen size, and one with a small screen size:
Note: Eclipse bug
Unfortunately eclipse currently does not acknowledge minSdkVersion and will not give you the option to test your application in any android virtual devices (AVD’s), while this is not fixed you can manually install the package into your AVD. For this you need to know the name of your emulator instance, to do this first run the AVD and then use the followin command to find out the name.
$adb devices List of devices attached emulator-5554 device
So we can see that the emulator instance I need is called emulator-5554. We can now use adb to install a package into this emulator. The below example shows installing wordcubefree from the bin folder in my project to my AVD using adb.
adb -s emulator-5554 install ~/android/workspace/WordCubeFree/bin/WordCubeFree.apk 1019 KB/s (39683 bytes in 0.038s) Can't dispatch DDM chunk 46454154: no handler defined Can't dispatch DDM chunk 4d505251: no handler defined pkg: /data/local/tmp/WordCubeFree.apk Success
Note that this will fail if the application is already installed and you will need to uninstall the application before using this command (if anyone knows a switch to force install or alternative method please let me know)
It is possible to delve into this is more detail by providing layouts for small, medium and large screen sizes. This can be explored in more detail in the google dev support guide