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