I am trying to port my application developed for smartphones to the tablets with minor modifications. Is there an API in Android to detect if the device is tablet?
place this method in onResume() and can check.
public double tabletSize() {
double size = 0;
try {
// Compute screen size
DisplayMetrics dm = context.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(Throwable t) {
}
return size;
}
generally tablets starts after 6 inch size.