欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

判断用户使用的是 Android 手机还是平板,android平板,private bool

来源: javaer 分享于  点击 45519 次 点评:44

判断用户使用的是 Android 手机还是平板,android平板,private bool


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;}//该片段来自于http://byrx.net
相关栏目:

用户点评