user2601652
user2601652

Reputation: 467

How to restrict that app will not run on tablet only not on phone

I am making an application which must run only on tablet not phones. I use this code but its installed even in mobile also.

Please help me how to make application for tablet only.

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

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

Upvotes: 1

Views: 1209

Answers (3)

Thkru
Thkru

Reputation: 4199

this may help you:

http://developer.android.com/guide/practices/screens-distribution.html http://developer.android.com/guide/topics/manifest/compatible-screens-element.html http://developer.android.com/google/play/publishing/multiple-apks.html

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

.

Android Market filters the application if the device screen size and density does not match any of the screen configurations ....

See also How can I ensure that my app is only available to phones on Android Market?

Upvotes: 1

Dixit Patel
Dixit Patel

Reputation: 3192

if you want your application to be available only to tablet devices, you can declare the element in your manifest like this:

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

for more refer this Link

Upvotes: 1

Flavio Capaccio
Flavio Capaccio

Reputation: 706

You can use this code to detect if device is a Tablet:

public boolean isTablet() {
        Log.d(Constants.TAG, "CHECK_TABLET isTablet entry["+isTablet+"]");
        if (isTablet == null) {
            int deviceSizeMask = getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK;
            float screenDensity = getResources().getDisplayMetrics().density;




            if (deviceSizeMask == Configuration.SCREENLAYOUT_SIZE_XLARGE
                    || (deviceSizeMask == Configuration.SCREENLAYOUT_SIZE_LARGE && screenDensity < 2.0f)) {
                isTablet = true;
            } else {
                isTablet = false;
            }

            Log.d(Constants.TAG, "CHECK_TABLET deviceSizeMask["+deviceSizeMask+"] screenDensity["+screenDensity+"] isTablet["+isTablet+"]");
        }
        Log.d(Constants.TAG, "CHECK_TABLET isTablet exit["+isTablet+"]");
        return isTablet;
    }

Upvotes: -1

Related Questions