Reputation: 1298
How can I find the device is a smart phone or table through my program? I tried with all fields of android.os.Build class. The info which I got is
OS Version: 2.6.35.7(DXKL2)
OS API Level: 10
Device: GT-S5360
Model (and Product): GT-S5360 (GT-S5360)
Board: totoro
Brand: samsung
CPU_ABI: armeabi
Display: GINGERBREAD.DXKL2
Fingerprint: samsung/GT-S5360/GT-S5360:2.3.6/GINGERBREAD/DXKL2:user/release-keys
Host: DELL152
Id: GINGERBREAD
Manufacturer: samsung
Type: user
User: root
This information is not helpful for me. Can someone tell me how to find it?
Upvotes: 2
Views: 2133
Reputation: 4341
You can check the screen density calling this code:
int screen_density = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
if (screen_density == Configuration.SCREENLAYOUT_SIZE_LARGE || screen_density == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
//The device is a tablet or at least has the screen density of a tablet
}
You can also get the screen size with the code below:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Finally, keep in mind that android Honeycomb(3.+) runs only in tablet so you can check the version of Android using:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if(currentapiVersion == android.os.Build.VERSION_CODES.HONEYCOMB ||
currentapiVersion == android.os.Build.VERSION_CODES.HONEYCOMB_MR1 ||
currentapiVersion == android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
//The device is a tablet
}
EDIT: Just to clarrify, the above code asumes that you are interested in device screen size and density for classifying a device as tablet. As stated from the answer of Michael Kohne there are many technical aspects that makes this classification difficult (if not impossible).
Hope this helps:)
Upvotes: 2
Reputation: 12044
What do you really want to know? Do you want to know if the device can make calls? Do you want to know how big the screen is? There are APIs for finding out those things.
'Smartphone' and 'Tablet' are marketing labels - they don't really mean a whole lot at a technical level, because one could make a tablet sized device that makes calls over the cell network, and one could make a phone-sized device that doesn't have any network beyond wi-fi!
Tell us what you actually want to know, and we can point you to the proper APIs.
Upvotes: 3