Android development needs to be adapted to mobile phones and tablets, and some needs to be judged when the device is mobile or tablet.
Many on the internet say through the device size, DPI, version number, whether the telephone function, etc. to judge, but are not too accurate.
Here's a simple way to share your strength (official usage):
/**@param @return */public static Boolean Ispad (Context context) { return (Context.getresources (). GetConfiguration (). Screenlayout & configuration.screenlayout_size_mask) >= Configuration.screenlayout_size_large;}
Make sure that you have a telephone function judgment method (now some tablets can also call):
Public Static Boolean Ispad (activity activity) { = (Telephonymanager) Activity.getsystemservice (context.telephony_ SERVICE); if (Telephony.getphonetype () = = Telephonymanager.phone_type_none) {returntrue ; } Else { returnfalse; }}
As for the device size, resolution, version number, to the current mobile phone, the individual believes that the accuracy is too poor, not recommended to use.
Android to determine whether the current device is a mobile phone or tablet