Home | History | Annotate | Download | only in practices
      1 page.title=Strategies for Android 1.5
      2 parent.title=Supporting Multiple Screens
      3 parent.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
     13 configuration, by default</li>
     14     <li>There are some simple steps you should take to enable support for multiple screens in
     15 an 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
     26 href="{@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
     34 baseline HVGA screen used on the T-Mobile G1 and similar devices, which is <em>normal</em> screen
     35 size and medium density (<em>mdpi</em>). Android 1.6 introduced support for different screen
     36 configurations and added APIs that allow applications to control how they operate on different
     37 screens, using alternative resources for different screen configurations.</p>
     38 
     39 <p>If your manifest file includes the <a
     40 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk&gt;}</a> element,
     41 with the <a
     42 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
     43 attribute set to {@code "3"} or lower, and does <em>not</em> include the <a
     44 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
     45 android:targetSdkVersion}</a> set to {@code "4"} or higher, then this document is for you. By
     46 default, an application written for Android 1.5 or below that does not set the <a
     47 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
     48 android:targetSdkVersion}</a> set to {@code "4"} or higher runs in <a
     49 href="screen-compat-mode.html">screen compatibility mode</a> when on a device with a screen larger than
     50 the
     51 <em>normal</em> screen size (basically, the system displays the application in a small window
     52 that is roughly the size of the normal screen size).</p>
     53 
     54 <p>This document describes how to get your application out of <a
     55 href="screen-compat-mode.html">screen compatibility
     56 mode</a> and instead support multiple screens, but also maintain compatibility with Android 1.5 and
     57 below.</p>
     58 
     59 <p class="note"><strong>Note:</strong> Before you begin, you should first decide whether it's even
     60 necessary to support Android 1.5. To see the relative number of devices that are still running
     61 Android 1.5, see the <a
     62 href="http://developer.android.com/about/dashboards/index.html">Platform Versions
     63 Dashboard</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
     71 Android 1.5 or earlier platform version, and want to maintain compatibility with Android 1.5, you
     72 need to make some changes to your application in order for it to properly run on newer devices with
     73 different screen configurations. You should be able to make these changes to your application such
     74 that 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
     77 lowest version that includes support for multiple screens) and test your application on each
     78 platform version your application supports (especially the minimum platform, such as Android 1.5).
     79 Here's how to do that:</p>
     80 
     81 <ol>
     82   <li>Maintain compatibility with existing devices by leaving your application's <a
     83 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
     84 attribute as it is. You <em>do not</em> need to increment the value of the attribute to support new
     85 devices and multiple screens. </li>
     86   <li>Extend compatibility for Android 1.6 (and higher) devices by adding <a
     87 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
     88 android:targetSdkVersion}</a> to the <a
     89 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk&gt;}</a> element.
     90 Set the value of <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
     91 android:targetSdkVersion}</a> to <code>"4"</code>. This allows your application to "inherit" the
     92 platform's multiple screens support, even though it is technically using an earlier version of the
     93 API.
     94   <p>Adding this attribute will cause an error in the compiler, because the attribute is unknown to
     95 Android 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
     97 Level 4) library, rather than against the Android 1.5 (or earlier) library. You must do this in
     98 order for your application to successfully compile when using the new manifest attributes. Older
     99 versions of the platform simply ignore the attributes they don't know, so your application still
    100 runs 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
    104 Android 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
    110 that use the screen sizes and densities that you want to support. When you create the AVDs, make
    111 sure to select the Android 1.6 or higher platform as the system image to use. For more information,
    112 see <a href="{@docRoot}guide/practices/screens_support.html#testing">How to Test Your Application on
    113 Multiple Screens</a>.</li>
    114   <li>Set up AVDs for testing your application on older versions of the platform, as low as the
    115 version declared by your <a
    116 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>.
    117 You need AVDs running the older platforms you are targeting, so that you can ensure there are
    118 no functional regressions.</li>
    119   <li>Compile your application against the Android 1.6 library and run it on the AVDs you created.
    120 Observe 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
    122 your application code, <span style="color:red">make certain not to use any APIs
    123 introduced later than the version declared by your <a
    124 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
    125 android:minSdkVersion}</a></span>. If you
    126 are in doubt, refer to SDK reference documentation and look for the API Level specifier for the API
    127 you want to use. Using newer APIs not supported by your minimum version will mean that your
    128 application 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.
    132 Users of devices with QVGA resolution at low density may want to download your application, so you
    133 should understand how your application will look and function on a small-screen device. In some
    134 cases, the reduced screen area and density mean that you need to make tradeoffs in design on those
    135 devices.</p>
    136 
    137 <p>Also give extra attention to testing your application on an AVD that emulates an <em>xlarge</em>
    138 screen. Devices with extra large screens are tablet-sized or larger, so you should pay close
    139 attention to how usable your application is on such screens. You might want to design new layouts
    140 specifically for extra large screens, to address usability aspects such as the location and size of
    141 buttons in your UI. To test your application on an extra large screen, create an AVD targeted to
    142 Android 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
    145 href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a> to add
    146 complete support for different screen configurations.</p>
    147 
    148