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