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