- 论坛徽章:
- 1
|
平时我们可以看到QQ上显示用户用的是手机还是平板,那么如何实现呢?
[Java]代码- 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;
- }
复制代码 如果有帮助那么看看,如果没帮助或没用,勿喷。 |
|