I am stuck while detecting tablet or smartphone. I have the application that should work on tablet as well as phone. I am not able to conclude how to code to detect the device. I have created the layouts for both tablet and phone.
I want to use is Tablet()
.
Asked
Active
Viewed 717 times
0
-
https://chat.stackoverflow.com/rooms/195083/taven-at-stackoverflow @Shruti – Pie Jun 22 '19 at 07:47
-
3Possible duplicate of [Tablet or Phone - Android](https://stackoverflow.com/questions/5832368/tablet-or-phone-android) – Reaz Murshed Jun 22 '19 at 07:51
1 Answers
0
values/string.xml
<bool name="is_tablet">false</bool>
values/sw900dp/sting.xml
or
values/sw600dp/string.xml
or
values/sw720dp/string.xml
<bool name="is_tablet">true</bool>
check this;
boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
If it's " dimen
", you can put it in dimen.

Hasan Kucuk
- 2,433
- 6
- 19
- 41