Here is another solution using simple flag :
Set the boolean value in the file to a specific value, for example say ( res/values-xlarge/ ):
<resources> <bool name="isTabletDevice">true</bool> </resources>
Then in the "standard" file of value, for example say ( res/values/ ):
<resources> <bool name="isTabletDevice">false</bool> </resources>
Then from your activity select this flag value to check device type :
boolean tabletDeviceSize = getResources().getBoolean(R.bool.isTabletDevice); if (tabletDeviceSize) { //use tablet link } else { //use mobile link }
Thanks.
source share