1page.title=Strategies for Android 1.5 2excludeFromSuggestions=true 3parent.title=Supporting Multiple Screens 4parent.link=screens_support.html 5 6@jd:body 7 8<div id="qv-wrapper"> 9<div id="qv"> 10 11 <h2>Quickview</h2> 12 <ul> 13 <li>Apps developed for Android 1.5 and below support only the baseline screen 14configuration, by default</li> 15 <li>There are some simple steps you should take to enable support for multiple screens in 16an application designed for Android 1.5</li> 17 </ul> 18 19 <h2>In this document</h2> 20 <ol> 21 <li><a href="#strategies">Adding Multiple Screens Support</a></li> 22 </ol> 23 24 <h2>See also</h2> 25 <ol> 26 <li><a 27href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li> 28 </ol> 29 30</div> 31</div> 32 33 34<p>All applications written for Android 1.5 or earlier, by default, support only the 35baseline HVGA screen used on the T-Mobile G1 and similar devices, which is <em>normal</em> screen 36size and medium density (<em>mdpi</em>). Android 1.6 introduced support for different screen 37configurations and added APIs that allow applications to control how they operate on different 38screens, using alternative resources for different screen configurations.</p> 39 40<p>If your manifest file includes the <a 41href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element, 42with the <a 43href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a> 44attribute set to {@code "3"} or lower, and does <em>not</em> include the <a 45href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 46android:targetSdkVersion}</a> set to {@code "4"} or higher, then this document is for you. By 47default, an application written for Android 1.5 or below that does not set the <a 48href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 49android:targetSdkVersion}</a> set to {@code "4"} or higher runs in <a 50href="screen-compat-mode.html">screen compatibility mode</a> when on a device with a screen larger than 51the 52<em>normal</em> screen size (basically, the system displays the application in a small window 53that is roughly the size of the normal screen size).</p> 54 55<p>This document describes how to get your application out of <a 56href="screen-compat-mode.html">screen compatibility 57mode</a> and instead support multiple screens, but also maintain compatibility with Android 1.5 and 58below.</p> 59 60<p class="note"><strong>Note:</strong> Before you begin, you should first decide whether it's even 61necessary to support Android 1.5. To see the relative number of devices that are still running 62Android 1.5, see the <a 63href="http://developer.android.com/about/dashboards/index.html">Platform Versions 64Dashboard</a>.</p> 65 66 67 68 69<h2 id="strategies">Adding Multiple Screens Support</h2> 70 71<p>If you have already developed and published an Android application based on 72Android 1.5 or earlier platform version, and want to maintain compatibility with Android 1.5, you 73need to make some changes to your application in order for it to properly run on newer devices with 74different screen configurations. You should be able to make these changes to your application such 75that you can distribute a single {@code .apk} to all devices.</p> 76 77<p>The recommended strategy is to develop your application against Android 1.6 (because it's the 78lowest version that includes support for multiple screens) and test your application on each 79platform version your application supports (especially the minimum platform, such as Android 1.5). 80Here's how to do that:</p> 81 82<ol> 83 <li>Maintain compatibility with existing devices by leaving your application's <a 84href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a> 85attribute as it is. You <em>do not</em> need to increment the value of the attribute to support new 86devices and multiple screens. </li> 87 <li>Extend compatibility for Android 1.6 (and higher) devices by adding <a 88href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 89android:targetSdkVersion}</a> to the <a 90href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> element. 91Set the value of <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code 92android:targetSdkVersion}</a> to <code>"4"</code>. This allows your application to "inherit" the 93platform's multiple screens support, even though it is technically using an earlier version of the 94API. 95 <p>Adding this attribute will cause an error in the compiler, because the attribute is unknown to 96Android 1.5. You'll fix this next.</p></li> 97 <li>Change your application's build properties, such that it compiles against the Android 1.6 (API 98Level 4) library, rather than against the Android 1.5 (or earlier) library. You must do this in 99order for your application to successfully compile when using the new manifest attributes. Older 100versions of the platform simply ignore the attributes they don't know, so your application still 101runs fine on them, as long as you don't use APIs in your application code from Android 1.6. </li> 102</ol> 103 104<p>Your application is now prepared to run on multiple screens, while maintaining support for 105Android 1.5 or lower.</p> 106 107<p>Here's how you should begin testing your application:</p> 108 109<ol> 110 <li>Set up AVDs for testing your application on Android 1.6 and some new versions. Create AVDs 111that use the screen sizes and densities that you want to support. When you create the AVDs, make 112sure to select the Android 1.6 or higher platform as the system image to use. For more information, 113see <a href="{@docRoot}guide/practices/screens_support.html#testing">How to Test Your Application on 114Multiple Screens</a>.</li> 115 <li>Set up AVDs for testing your application on older versions of the platform, as low as the 116version declared by your <a 117href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>. 118You need AVDs running the older platforms you are targeting, so that you can ensure there are 119no functional regressions.</li> 120 <li>Compile your application against the Android 1.6 library and run it on the AVDs you created. 121Observe the way your application looks and runs, and test all of the user interactions.</li> 122 <li>Debug any display or functional issues. For issues that you resolve in 123your application code, <span style="color:red">make certain not to use any APIs 124introduced later than the version declared by your <a 125href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code 126android:minSdkVersion}</a></span>. If you 127are in doubt, refer to SDK reference documentation and look for the API Level specifier for the API 128you want to use. Using newer APIs not supported by your minimum version will mean that your 129application will no longer be compatible with devices running on that version.</li> 130</ol> 131 132<p>In particular, remember to test your application on an AVD that emulates a small-screen device. 133Users of devices with QVGA resolution at low density may want to download your application, so you 134should understand how your application will look and function on a small-screen device. In some 135cases, the reduced screen area and density mean that you need to make tradeoffs in design on those 136devices.</p> 137 138<p>Also give extra attention to testing your application on an AVD that emulates an <em>xlarge</em> 139screen. Devices with extra large screens are tablet-sized or larger, so you should pay close 140attention to how usable your application is on such screens. You might want to design new layouts 141specifically for extra large screens, to address usability aspects such as the location and size of 142buttons in your UI. To test your application on an extra large screen, create an AVD targeted to 143Android 3.0 and use the WXGA emulator skin.</p> 144 145<p>Once you've completed the procedures above, you should follow the recommendations in <a 146href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a> to add 147complete support for different screen configurations.</p> 148 149