How to prevent app installing on tablet in Android

2019-08-08 03:39发布

问题:

I am told to build an app in Android 2.2 which will not support tablets.

I went through lots of googling but found no solution. I also found this link but this give how to do the same from 2.3 onwards.

My problem is that I can't switch to 2.3 as my client want to support the app from 2.2.

Here is the code I am using in my manifest

<supports-screens android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true"/>

The code above doesn't prevent the app to download from tablet, and so it crashes.

回答1:

The code in that link will work fine. Set your sdkTarget to 2.3 and your minSDK as 2.2.



回答2:

A little bit unexpected answer, I think, but have your tried to ignore screen sizes completely and just request PHONE features in the manifest? It's quite rare for a tablet to have those, so you effectively filter 'em out. For example, your may write in your AndroidManifest.xml:

<uses-permission android:name="android.permission.CALL_PHONE" />


回答3:

try below code

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