2

How to separate android device as per the screen size. I have a apk which should run from Android version 3, but I want to run that application only on tablet not for normal devices. I am not sure how to do this stuff. I think

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

This code will help to do my need. But is there any other way to restrict the device when install from google play.

Renjith
  • 5,783
  • 9
  • 31
  • 42
RAAAAM
  • 3,378
  • 19
  • 59
  • 108
  • Yes, when you upload the APK, you can select which devices it can be downloaded for, just go there, deselect all and re-select the tablets. – LuckyMe Jul 23 '13 at 05:12
  • http://stackoverflow.com/a/17585605/1835764 might be help you. – Nirmal Jul 23 '13 at 05:39
  • So do you want the app to now show up in the Google play at all for any devices not tablets? or do you want to just merely close when launched if it is not a tablet? Also note that there is nothing special that identifies tablets from other devices, that is because Android is meant to work on any device. – LuckyMe Jul 23 '13 at 07:38

3 Answers3

0

You are developing native or phonegap application?If it is phonegap app, you can use media queries to restrict the screen sizes.

joe
  • 221
  • 2
  • 5
  • 13
0

Yes it is possible You may do like this :

Designing an android tablet-only app

Hope it helps :)

Community
  • 1
  • 1
Araib karim
  • 421
  • 4
  • 16
  • Great. thanks!! i think i got the answer for my question. This will help me lot. I accept your answer once it works fine :) – RAAAAM Jul 23 '13 at 05:25
0

Try using this

DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    int widthInPixels = metrics.widthPixels;
    int heightInPixels = metrics.heightPixels;

    if (widthInPixels > 600 || heightInPixels > 600) {
        // This is a tablet dont run
    }

OR

if(tabletSize() > 6)
        Log.d("Testing", "Is Tablet ");
    else
        Log.d("Testing", "Not a Tablet ");

public double tabletSize() {

    double size = 0;
    try {
        // Compute screen size
        DisplayMetrics dm = getApplicationContext().getResources().getDisplayMetrics();
        float screenWidth = dm.widthPixels / dm.xdpi;
        float screenHeight = dm.heightPixels / dm.ydpi;
        size = Math.sqrt(Math.pow(screenWidth, 2) +
        Math.pow(screenHeight, 2));
    } catch (Exception e) {
        Log.e("Testing", "Exception " + e);
    }
    return size;
}

This will give you the size of the device in inch's so you can restrict it to a particular screen size (Normally a table is > 6)

Girish Nair
  • 5,148
  • 5
  • 40
  • 61
  • Thanks Girish, i know this concept. but i want to separate my application from google play itself not after installed application. – RAAAAM Jul 23 '13 at 05:33