I’m writing an app which will be used mainly on phones, but which some users will use on a tablet. For the tablet users I want to configure some additional features. I’m testing it on a phone (Galaxy S phone – 480 x 800) and a tablet (Galaxy Tab 10.1″ – 800 x 1280). Using the following code . . .
if ((getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
Toast.makeText(this, "Tablet",Toast.LENGTH_LONG).show();
}
else if ((getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
Toast.makeText(this, "Phone" , Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(this, "Neither" , Toast.LENGTH_LONG).show();
}
. . . the phone comes up as “phone” and the tablet comes up as “neither”. But the Android documentation says that SCREENLAYOUT_SIZE_LARGE is “at least approximately 480×640 dp units.”
BTW, getResources().getConfiguration() on the tablet says screenWidthDp is 1280 and screenHeightDp is 752. So what am I doing wrong that the tablet isn’t getting detected?
Thanks in advance.
just tested on my Galaxy Tab:
You need to also heck for Configuration.SCREENLAYOUT_SIZE_XLARGE.