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 telephony = (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.
Other great article articles
Android Learning Notes ($) Android Options Menu and submenu (submenu) Android Learning note (notification) features and usage of Android Learning notes ($) Android using listeners to listen to menu events Android Learning notes (+) Android Create a single-selection menu and a check menu for jquery tutorials ( -ajax operations based on request load Data jquery tutorial (-ajax) append HTML for operationmore about Android Development articles
Android to determine whether the current device is a mobile phone or tablet