0

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().

Ramesh R
  • 7,009
  • 4
  • 25
  • 38
Shruti
  • 9
  • 1

1 Answers1

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