1page.title=Distributing to Specific Screens 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>If necessary, you can control distribution of your application based on the device 14screen configuration</li> 15 </ul> 16 17 <h2>In this document</h2> 18 <ol> 19 <li><a href="#FilteringHansetApps">Declaring an App is Only for Handsets</a></li> 20 <li><a href="#FilteringTabletApps">Declaring an App is Only for Tablets</a></li> 21 <li><a href="#MultiApks">Publishing Multiple APKs for Different Screens</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 <li><a 29href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for Android 3.0</a></li> 30 </ol> 31 32</div> 33</div> 34 35 36 37<p>Although we recommend that you design your application to function properly on multiple 38configurations of screen size and density, you can instead choose to limit the distribution of your 39application to certain types of screens, such as only tablets and other large devices or only 40handsets and similar-sized devices. To do so, you can enable filtering by external services such as 41Google Play by adding elements to your manifest file that specify the screen configurations your 42application supports.</p> 43 44<p>However, before you decide to restrict your application to certain screen configurations, you 45should understand the techniques for <a 46href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a> and implement 47them to the best of your ability. By supporting multiple screens, your application can be made 48available to the greatest number of users with different devices, using a single APK.</p> 49 50 51 52<h2 id="FilteringHandsetApps">Declaring an App is Only for Handsets</h2> 53 54<p>Because the system generally scales applications to fit larger screens well, you shouldn't 55need to filter your application from larger screens. As long as you follow the <a 56href="{@docRoot}guide/practices/screens_support.html#screen-independence">Best Practices for Screen 57Independence</a>, your application should work well on larger screens such as tablets. However, you 58might discover that your application can't scale up well or perhaps you've decided to publish two 59versions of your application for different screen configurations. In such a case, you can use the <a 60href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code 61<compatible-screens>}</a> element to manage the distribution of your application based on 62combinations of screen size and density. External services such as Google Play use this 63information to apply filtering to your application, so that only devices that have a screen 64configuration with which you declare compatibility can download your application.</p> 65 66<p>The <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code 67<compatible-screens>}</a> element must contain one or more {@code <screen>} elements. Each 68{@code <screen>} element specifies a screen configuration with which your application is 69compatible, using both the {@code android:screenSize} and {@code android:screenDensity} attributes. 70Each {@code <screen>} element <strong>must include both attributes</strong> to specify an 71individual screen configuration—if either attribute is missing, then the element is invalid 72(external services such as Google Play will ignore it).</p> 73 74<p>For example, if your application is compatible with only small and normal size screens, 75regardless of screen density, you must specify eight different {@code <screen>} elements, 76because each screen size has four density configurations. You must declare each one of 77these; any combination of size and density that you do <em>not</em> specify is considered a screen 78configuration with which your application is <em>not</em> compatible. Here's what the manifest 79entry looks like if your application is compatible with only small and normal screen sizes:</p> 80 81<pre> 82<manifest ... > 83 <compatible-screens> 84 <!-- all small size screens --> 85 <screen android:screenSize="small" android:screenDensity="ldpi" /> 86 <screen android:screenSize="small" android:screenDensity="mdpi" /> 87 <screen android:screenSize="small" android:screenDensity="hdpi" /> 88 <screen android:screenSize="small" android:screenDensity="xhdpi" /> 89 <!-- all normal size screens --> 90 <screen android:screenSize="normal" android:screenDensity="ldpi" /> 91 <screen android:screenSize="normal" android:screenDensity="mdpi" /> 92 <screen android:screenSize="normal" android:screenDensity="hdpi" /> 93 <screen android:screenSize="normal" android:screenDensity="xhdpi" /> 94 </compatible-screens> 95 ... 96 <application ... > 97 ... 98 <application> 99</manifest> 100</pre> 101 102<p class="note"><strong>Note:</strong> Although you can also use the <a 103href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code 104<compatible-screens>}</a> element for the reverse scenario (when your application is not 105compatible with smaller screens), it's easier if you instead use the <a 106href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code 107<supports-screens>}</a> as discussed in the next section, because it doesn't require you 108to specify each screen density your application supports.</p> 109 110 111 112 113<h2 id="FilteringTabletApps">Declaring an App is Only for Tablets</h2> 114 115<p>If you don't want your app to be used on handsets (perhaps your app truly makes sense only on a 116large screen) or you need time to optimize it for smaller screens, you can prevent small-screen 117devices from downloading your app by using the <a 118href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code 119<supports-screens>}</a> manifest element.</p> 120 121<p>For example, if you want your application to be available only to tablet devices, you can declare 122the element in your manifest like this:</p> 123 124<pre> 125<manifest ... > 126 <supports-screens android:smallScreens="false" 127 android:normalScreens="false" 128 android:largeScreens="true" 129 android:xlargeScreens="true" 130 android:requiresSmallestWidthDp="600" /> 131 ... 132 <application ... > 133 ... 134 </application> 135</manifest> 136</pre> 137 138<p>This describes your app's screen-size support in two different ways:</p> 139 140<ul> 141 <li>It declares that the app does <em>not</em> support the screen sizes "small" and 142"normal", which are traditionally not tablets.</li> 143 <li>It declares that the app requires a screen size with a minimum usable area that is at least 144600dp wide.</li> 145</ul> 146 147<p>The first technique is for devices that are running Android 3.1 or older, because those devices 148declare their size based on generalized screen sizes. The <a 149href="{@docRoot}guide/topics/manifest/supports-screens-element.html#requiresSmallest">{@code 150requiresSmallestWidthDp}</a> attribute is for devices running Android 3.2 and newer, which includes 151the capability for apps to specify size requirements based on a minimum number of 152density-independent pixels available. In this example, the app declares a minimum width requirement 153of 600dp, which generally implies a 7"-or-greater screen. </p> 154 155<p>Your size choice might be different, of course, based on how well your design works on different 156screen sizes; for example, if your design works well only on screens that are 9" or larger, you 157might require a minimum width of 720dp.</p> 158 159<p>The catch is that you must compile your application against Android 3.2 or higher in order to use 160the <code>requiresSmallestWidthDp</code> attribute. Older versions don't understand this attribute 161and will raise a compile-time error. The safest thing to do is develop your app against the platform 162that matches the API level you've set for <a 163href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">minSdkVersion</a 164>. When you're making final preparations to build your release candidate, change the build target to 165Android 3.2 and add the <code>requiresSmallestWidthDp</code> attribute. Android versions older than 1663.2 simply ignore that XML attribute, so there's no risk of a runtime failure.</p> 167 168<p>For more information about why the "smallest width" screen size is 169important for supporting different screen sizes, read <a 170href="http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html">New 171Tools for Managing Screen Sizes</a>.</p> 172 173<p class="caution"><strong>Caution:</strong> If you use the <a 174href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code 175<supports-screens>}</a> element for the reverse scenario (when your application is not compatible 176with <em>larger</em> screens) and set the larger screen size attributes to {@code "false"}, then 177external services such as Google Play <strong>do not</strong> apply filtering. Your application 178will still be available to larger screens, but when it runs, it will not resize to fit the screen. 179Instead, the system will emulate a handset screen size (about 320dp x 480dp; see <a 180href="{@docRoot}guide/practices/screen-compat-mode.html">Screen Compatibility Mode</a> for more 181information). If you want 182to prevent your application from being downloaded on larger screens, use <a 183href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code 184<compatible-screens>}</a>, as discussed in the previous section about <a 185href="#FilteringHandsetApps">Declaring an App is Only for Handsets</a>.</p> 186 187<p>Remember, you should strive to make your application available to as many devices as possible by 188applying all necessary techniques for <a 189href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a>. You should 190use <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code 191<compatible-screens>}</a> or <a 192href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code 193<supports-screens>}</a> only when you cannot provide compatibility on all screen configurations 194or you have decided to provide different versions of your application for different sets of screen 195configurations.</p> 196 197 198 199<h2 id="MultiApks">Publishing Multiple APKs for Different Screens</h2> 200 201<p>Although we recommend that you publish one APK for your application, Google Play allows 202you to publish multiple APKs for the same 203application when each APK supports a different set of screen configurations (as declared in 204the manifest file). For example, if you want to publish both a handset version and a tablet 205version of your application, but you're unable to make the same APK work for both screen sizes, 206you can actually publish two APKs for the same application listing. Depending on each device's 207screen configuration, Google Play will deliver it the APK that you've declared to support that 208device's screen.</p> 209 210<p>Beware, however, that publishing multiple APKs for the same application is 211considered an advanced feature and <strong>most applications should publish only one 212APK that can support a wide range of device configurations</strong>. Supporting multiple screen 213sizes, especially, is within reason using a single APK, as long as you follow the guide to 214<a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>.</p> 215 216<p>If you need more information about how to publish multiple APKs on Google Play, read <a 217href="{@docRoot}google/play/publishing/multiple-apks.html">Multiple APK Support</a>.</p> 218