Created
December 3, 2011 19:56
-
-
Save jimmy-collazos/1427969 to your computer and use it in GitHub Desktop.
Snippet/Android: Detected Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isTabletDevice() { | |
if (android.os.Build.VERSION.SDK_INT >= 11) { // honeycomb | |
// test screen size, use reflection because isLayoutSizeAtLeast is only available since 11 | |
Configuration con = getResources().getConfiguration(); | |
try { | |
Method mIsLayoutSizeAtLeast = con.getClass().getMethod("isLayoutSizeAtLeast", int.class); | |
Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con, 0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE | |
return r; | |
} catch (Exception x) { | |
x.printStackTrace(); | |
return false; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment