32

Let's say that I want to build 2 different sets of tablet-only layouts. One for 600dp (7" tablet 1024x600) and one for 720dp (10" tablet 1280x720 or 1280x800)

I understand that with android 3.2 you can now specify the tablet layouts. I understand that but how to specify on Google Play that this is a tablet-only app.

There is this android:requiresSmallestWidthDp to specify the minimum smallestWidth required. Fine but later on the guide you can read

Caution: The Android system does not pay attention to this attribute, so it does not affect how your application behaves at runtime. Instead, it is used to enable filtering for your application on services such as Google Play. However, Google Play currently does not support this attribute for filtering (on Android 3.2), so you should continue using the other size attributes if your application does not support small screens.

So it's not used by the system and not used by Google Play...so basically it's useless ,right ?

"You should continue using the other size attributes if your application does not support small screens.

Ok. What other size attribute? The supports-screens one ? Xlarge : screens are at least 960dp x 720dp large : screens are at least 640dp x 480dp

The 1024x600 7" tablet is a "large" screen. So I basically have to design a layout for the 640x480 res. too because if I want my app to be available for the 2 different sizes of tablets, I have to enable large and xlarge screens.

So I guess that I could build 2 different sets of layouts like this

res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

and completely omit to specify a layout for smaller screens but then the app would crash on a smaller screen. That's a way to prevent the app from running that sure is not elegant.

Is there a way to make the app available only for the 600dp and greater screens on Google-Play? I'm quite confused. I want to make a tablet-only app that a 640x480 phone could not download on Google-Play. I guess I'm missing something very obvious.

Jim S
  • 427
  • 1
  • 6
  • 12

1 Answers1

52

To get your app filtered for just Tablets running ICS in Google-Play you would do this in your AndroidManifest:

<supports-screens
        android:largeScreens="true"
        android:normalScreens="false"
        android:requiresSmallestWidthDp="600"
        android:smallScreens="false"
        android:xlargeScreens="true" />

 <uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="14" />

To get HoneyComb Tablets aswell you simply change your minSdk

 <uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="14" />

Therefore your now saying Gingerbread (2.3) and below can't download your app (because they are not Tablets nor designed to work on tablets even if it is hacked in).

HoneyComb Tablets (3.0) is supported (because <3.2 is ignoring the requiresSmallestWidth attribute)

There are no phones running honeycomb

ICS Tablets are supported because it does look at your smallestWidth attribute

and finally ICS phones aren't because as we say ICS uses the smallestWidth attribute

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • Thanks. My only concern is that on this page http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts it says "Google Play currently does not support this attribute for filtering (on Android 3.2)". So you're saying that this attribute/filter is used on ics phones and tablets? I wish the docs was more clear on that. – Jim S May 10 '12 at 21:11
  • 1
    `Google Play currently does not support this attribute for filtering (on Android 3.2)` on 3.2 , that is why I've written the above to account for honeycomb, but it will be used to filter on 4.0 devices – Blundell May 10 '12 at 21:15
  • This was great reference, i have a doubt, if my application is specific for landscape mode. If portrait we can specify 600 is the limit for width, but what for landscape application. i mentioned "android:screenOrientation="landscape" in manifest. will this code consider width for landscape mode. – RAAAAM Jul 23 '13 at 06:08
  • `screenOrientation` won't affect it. The `android:requiresSmallestWidthDp` is for the device in either mode, i.e. it is the smallest width of the device, in port or land – Blundell Jul 23 '13 at 10:54
  • I would not filter tablets by minimum sdk version. I have seen tablets with original software running android 2.1, 2.2 and 2.3 – ElYeante Jan 16 '14 at 14:39
  • I used your manifest specs, but my customer with I9200 phone can still download my app. http://pdadb.net/index.php?m=specs&id=4429&c=samsung_gt-i9200_galaxy_mega_6.3_16gb – macio.Jun May 20 '14 at 15:35
  • This works for me, thank you! What would be the exact opposite? @Blundell – jazz Dec 02 '16 at 08:53