【转】Android编程判断手机or平板

转载自:http://www.cnblogs.com/sunzn/p/3663363.html

 

1 /**
2      * 判断当前设备是手机还是平板,代码来自 Google I/O App for Android
3      * @param context
4      * @return 平板返回 True,手机返回 False
5      */
6     public static boolean isTablet(Context context) {
7         return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
8     }

 

posted @ 2015-07-07 13:52  菊草叶与圆企鹅  阅读(195)  评论(0编辑  收藏  举报