How to check whether your app running in a Phone or in a Tablet ?
Step1: Create a Display Object which help us to retrieve the width and height of the device.
Step2 : Method which i had wrote below will return true if your app running in Tablet or it will return false.
public static boolean isTablet(Display display) {
Log.d("tablet", "isTablet() invoked");
final int width = display.getWidth();
final int height = display.getHeight();
switch (display.getOrientation()) {
case 0: case 2: // Landscape Mode
if(width > height) return true;
break;
case 1: case 3: // Portrait Mode
if(width < height) return true;
break;
}
return false;
}
No comments:
Post a Comment