Android: Disable application for tablet

18,540

Solution 1

Include following in your Manifest:

<manifest ... >
<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" />
    <screen android:screenSize="small" android:screenDensity="xxxhdpi" />
    <!-- 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" />
    <screen android:screenSize="normal" android:screenDensity="xxxhdpi" />
</compatible-screens>
</manifest>

This will help you.

Solution 2

This prevents access on tablets, but allows the new density buckets (xxhdpi and xxxhdpi) and avoids errors on projects that are compiled against lower SDKs. It should be a direct child of the <manifest> element in AndroidManifest.xml

<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="480" />
    <screen android:screenSize="small" android:screenDensity="640" />

    <!-- 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="480" />
    <screen android:screenSize="normal" android:screenDensity="560" />
    <screen android:screenSize="normal" android:screenDensity="640" />
</compatible-screens>

Update 8.8.2016 Add this line if you want to support Nexus-5x-like devices with 420 density

<screen android:screenSize="normal" android:screenDensity="420" />

Solution 3

If you want to restrict the app to handsets only use the <compatible-screens> tag in the Manifest. i.e.like this

<manifest ... >
    <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>
    ...
    <application ... >
        ...
    <application>
</manifest>

For more info check Declaring an App is Only for Handsets

You should not use the <supports-screens> tag, if you want to restrict the app from tablets. It is clearly mentioned in the official doc

Caution: If you use the element for the reverse scenario (when your application is not compatible with larger screens) and set the larger screen size attributes to "false", then external services such as Google Play do not apply filtering. Your application will still be available to larger screens, but when it runs, it will not resize to fit the screen. Instead, the system will emulate a handset screen size (about 320dp x 480dp; see Screen Compatibility Mode for more information). If you want to prevent your application from being downloaded on larger screens, use , as discussed in the previous section about Declaring an App is Only for Handsets.

Solution 4

please check if you have made layout for layout-large, layout-xlarge. if they are present your app will run on tablet, please remove that layout folder if present.

Share:
18,540

Related videos on Youtube

Manoj Fegde
Author by

Manoj Fegde

Android Developer 7+ year experience.

Updated on September 17, 2022

Comments

  • Manoj Fegde
    Manoj Fegde over 1 year

    I developed an application, Now i want to restrict the application for tablet.

    Means the application should not run on any tablets. For that I specify the support-screens in Androidmenifest.XML file as:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.abc.xyz"
    android:versionCode="1"
    android:versionName="1.0" >
    
    <uses-sdk
        android:minSdkVersion="5"
        android:targetSdkVersion="17"
        android:maxSdkVersion="17" />
    
    <supports-screens 
        android:smallScreens="true"
        android:normalScreens="true" 
        android:largeScreens="false"
        android:xlargeScreens="false"
        android:resizeable="true"
        android:anyDensity="true" />
    
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
    <application
        android:icon="@drawable/appicon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar"
        android:allowBackup="true" >
    
        <activity
            android:name="com.abc.xyz.activities.hello"
            android:label="@string/title_activity_hello" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>        
    </application>
    
    </manifest>
    

    Now the issue is that :

    Application is running on tablet

     android:largeScreens="false"
     android:xlargeScreens="false"
    

    After declaring above too.

    Now what should i do. Please suggest me and guide me.

  • Kevin van Mierlo
    Kevin van Mierlo almost 9 years
    I was missing all kinds of devices, this fixed that! Thanks!
  • geekoraul
    geekoraul about 8 years
    Will this work if my app already supports tablet and I don't want the tablets to get an update to a specific version ?
  • loshkin
    loshkin over 7 years
    With this configuration, devices like Nexus 5x(~423 ppi) are not included. Tested. You still have to add xxhdpi.
  • Rohan Patel
    Rohan Patel over 7 years
    What is mean by <screen android:screenSize="normal" android:screenDensity="480" /> <screen android:screenSize="normal" android:screenDensity="560" /> <screen android:screenSize="normal" android:screenDensity="640" />
  • tsalaroth
    tsalaroth about 7 years
    I believe it would be according to the API docs. The screenDensity attribute declares the dpi, and all of these are valid dpi values in the docs.
  • kostik
    kostik over 5 years
    I dont think is correct answer anymore. I could not install app on Samsung Galaxy S9+
  • Heaven
    Heaven about 5 years
    any new method now?