androidandroid-manifestandroid-screen-supportandroid-screen

Android: Disable application for tablet


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.


Solution

  • 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.