Is there a way to check if the user is using a tablet or a phone? I've got problems with my tilt function and my new tablet (Transformer)
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Well, the best solution that worked for me is quite simple:
Used like this:
I really don't want to look at the pixels sizes but only rely on the screen size.
Works well as Nexus 7 (LARGE) is detected as a tablet, but not Galaxy S3 (NORMAL).
Based on Robert Dale Johnson III and Helton Isac I came up with this code Hope this is useful
So in your code make a filter like
If screen size detection doesn't return correct value on newer devices, give a try:
Tested on Android 4.2.2 (sorry for my English.)
why use this?
i see many ways above.the Configuration class has get the right answer just below:
just call :
it's ok?
Why not calculate the size of the screen diagonal and use that to make the decision whether the device is a phone or tablet?
Of course one can argue whether the threshold should be 9 inches or less.
Thinking on the "new" acepted directories (values-sw600dp for example) i created this method based on the screen' width DP:
And on this list you can find some of the DP of popular devices and tablet sizes:
Wdp / Hdp
GALAXY Nexus: 360 / 567
XOOM: 1280 / 752
GALAXY NOTE: 400 / 615
NEXUS 7: 961 / 528
GALAXY TAB (>7 && <10): 1280 / 752
GALAXY S3: 360 / 615
Wdp = Width dp
Hdp = Height dp