コードを使った方法
調べると色々な方法がでてきますが
googleI/O 2015のアプリの中では以下のようにやってました。
public static boolean isTablet(Context context) {
return context.getResources().getConfiguration().smallestScreenWidthDp >= 600;
}
リソースを使った方法
一応リソースを使った方法も
res/values-sw600dp/bool.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_tablet">true</bool>
</resources>
res/values/bool.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_tablet">false</bool>
</resources>
判定
public static boolean isTablet(Context context) {
return context.getResources().getBoolean(R.bool.is_tablet);
}