Method One
Copy Code code as follows:
public static Boolean Istablet (context context) {
Return (Context.getresources (). GetConfiguration (). screenlayout
& Configuration.screenlayout_size_mask)
>= Configuration.screenlayout_size_large;
}
Method Two
To determine whether a cell phone or a tablet is done by calculating the size of the device:
Copy Code code as follows:
/**
* To determine whether the plate
*
* @return
*/
Private Boolean Ispad () {
WindowManager wm = (WindowManager) getsystemservice (Context.window_service);
Display display = Wm.getdefaultdisplay ();
Screen width
float screenwidth = Display.getwidth ();
Screen height
float screenheight = Display.getheight ();
Displaymetrics dm = new Displaymetrics ();
Display.getmetrics (DM);
Double x = Math.pow (dm.widthpixels/dm.xdpi, 2);
Double y = Math.pow (dm.heightpixels/dm.ydpi, 2);
Screen size
Double screeninches = math.sqrt (x + y);
Pad is greater than 6 size
if (screeninches >= 6.0) {
return true;
}
return false;
}