-2

I am making an android app for phones only. My UI is not optimized for tablets, so I don't want tablet users to use it. How do I restrict my app from working on tablets?

vergil corleone
  • 1,091
  • 3
  • 16
  • 34
  • 1
    Take a look at this answer: http://stackoverflow.com/questions/7636588/android-limit-supported-devices-in-android-market – Nomad101 May 01 '13 at 20:02

1 Answers1

3

You will have to use the <compatible-screens> element in your manifest to declare specifically what screen sizes and densities you wish to support.

The following example comes from the documentation on this subject:

<compatible-screens>
    <!-- all small size screens -->
    <screen android:screenSize="small" android:screenDensity="ldpi" />
    <screen android:screenSize="small" android:screenDensity="mdpi" />
    <screen android:screenSize="small" android:screenDensity="hdpi" />
    <screen android:screenSize="small" android:screenDensity="xhdpi" />
    <!-- all normal size screens -->
    <screen android:screenSize="normal" android:screenDensity="ldpi" />
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />
</compatible-screens>

Note that the sample is flawed, as it will block your app from appearing on -xxhdpi devices (e.g., SONY Xperia Z, Droid DNA). You would want to add another pair of <screen> elements for xxhdpi as well to cover that scenario:

<compatible-screens>
    <!-- all small size screens -->
    <screen android:screenSize="small" android:screenDensity="ldpi" />
    <screen android:screenSize="small" android:screenDensity="mdpi" />
    <screen android:screenSize="small" android:screenDensity="hdpi" />
    <screen android:screenSize="small" android:screenDensity="xhdpi" />
    <screen android:screenSize="small" android:screenDensity="xxhdpi" />
    <!-- all normal size screens -->
    <screen android:screenSize="normal" android:screenDensity="ldpi" />
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />
    <screen android:screenSize="normal" android:screenDensity="xxhdpi" />
</compatible-screens>
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • You mean I'll have to add this line to support Xperia Z: "" ? And are screenSize large and xlarge exclusively for tablets? – vergil corleone May 01 '13 at 20:13
  • Adding android:xlargeScreens="false" to – vergil corleone May 01 '13 at 20:29
  • @vergilcorleone: "And are screenSize large and xlarge exclusively for tablets?" -- there really is no such thing as a "tablet". `large` and `xlarge` cover devices that have screen sizes of 5" and above. Whether you consider those to be "tablets" is up to you. "Adding android:xlargeScreens="false" to – CommonsWare May 01 '13 at 20:35
  • Why won't adding android:xlargeScreens="false" to supports-screens work? – vergil corleone May 01 '13 at 21:34
  • @vergilcorleone: All you are saying there is that you have not written your own support for `-xlarge` screens. Android will therefore stretch your UI for you, and your app will still ship to `-xlarge` devices. – CommonsWare May 01 '13 at 21:37
  • Thanks for the replies. Can you elaborate on " You would want to add another pair of elements for xxhdpi as well to cover that scenario."? – vergil corleone May 01 '13 at 21:54
  • adding xxhdpi to the density prodices an error on compiling : "error: Error: String types not allowed (at 'screenDensity' with value 'xxhdpi')." – vergil corleone May 02 '13 at 00:55
  • @vergilcorleone: Either update your build target to something newer (API Level 16+ should work) or simply do not support `xxhdpi` devices. – CommonsWare May 02 '13 at 11:30
  • The build target is set to API level 17 already, the error is there still.. – vergil corleone May 02 '13 at 12:23
  • @vergilcorleone: OK, looks like there is a bug (https://code.google.com/p/android/issues/detail?id=39622) that is causing the problem. Change `xxhdpi` to `480` and try that. – CommonsWare May 02 '13 at 12:33
  • ok 480 works, hope it works on xxhdpi phones. – vergil corleone May 02 '13 at 13:14