Is current device tablet?
Question
Is there a way to determnine if current device tablet in Android 2.2 and higher?
Currently I'm using minimal screen dimension, but there is some tablets (Viewsonic ViewPad7 480x800) with resolution like phones or even smaller (e. g. HTC Evo 3D has 960x540).
Is there any hardware property to read?
Solution
There is no reliable difference between phones and tablets, it is only possible to point it using specific features, the below can be used in conjunction with each other
The String Build.VERSION.RELEASE will give you the user-visible version string (i.e 1.5, 1.6, 2.0), while Build.VERSION.SDK_INT will give you a value from Build.VERSION_CODES. Remember Build.VERSION.SDK_INT works on Android 1.6 higher but not for 1.5. Build.VERSION.SDK will work on 1.5 or higher.
- http://developer.android.com/reference/android/os/Build.html
- http://developer.android.com/reference/android/os/Build.VERSION.html
And DisplayMetrics describes general information about a display
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
OTHER TIPS
You can use getResources().getConfiguration()
For example:
getResources().getConfiguration().navigation
The following code will return the actual resolution of the physical device.
Display d = getWindowManager().getDefaultDisplay();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
int h = d.getWidth();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int w = d.getWidth();