0

I want to check if my device is a tablet or not.

What is the best implementation of method isMyDeviceATablet() or isMyDeviceATablet(Context context)?

Alex Lockwood
  • 82,434
  • 38
  • 201
  • 248
Bobs
  • 22,419
  • 38
  • 141
  • 223

1 Answers1

2

From the Google I/O 2011 app:

public static boolean isHoneycomb() {
    // Can use static final constants like HONEYCOMB, declared in 
    // later versions of the OS since they are inlined at compile 
    // time. This is guaranteed behavior.
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
}

public static boolean isTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK)
            >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

public static boolean isHoneycombTablet(Context context) {
    return isHoneycomb() && isTablet(context);
}
Alex Lockwood
  • 82,434
  • 38
  • 201
  • 248