Monday 24 December 2012

Check whether device is Tablet Programatically in Android

Hi folks! I am here sharing a simple code where you check your Android device is tablet or phone at run time programmatically.

/**
* To check device is tablet or not.
* @param context
* @return true if device is tablet
*/
public static boolean isTablet(Context context) {
      boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
      boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
   return (xlarge || large);
}


No comments:

Post a Comment