I am trying to detect 7″ tablets in my code (i.e. Kindle Fire & Nook Color). However, simply testing for minimum dimensions 1024×600 is not good, because then the Galaxy Nexus would pass this test as well. Anybody has experience with detecting this kind of information?
Thanks,
Igor
EDIT:
I have found one way to detect Kindle Fire & Nook Color devices with the following code:
Activity activity = (Activity) activityContext;
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
int height = activity.getWindowManager().getDefaultDisplay().getHeight();
if ((width == 1024 && height == 600) || (width == 600 && height == 1024)) {
//Detects 7" tablets: i.e. Kindle Fire & Nook Color
isTablet = true;
}
To calculate the height and width of the device (in inches) you can use the following code.
Then the size can be calculated
As per Commonsware suggestion above, a potentially faster, but less obvious implementation.