我可以从attrs资源中检测到设备类型:
<bool name="isTablet">false</bool>
// xlarge and sw600dp = tablet
// normal = phone
if(getResources().getBoolean(R.bool.isTablet)) {
// is tablet
}但一些较小的平板电脑被检测为手机。
发布于 2021-09-11 06:35:05
我认为你可以使用TelephonyManager类。
TelephonyManager manager = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
if (Objects.requireNonNull(manager).getPhoneType() == TelephonyManager.PHONE_TYPE_NONE){
//Tablet
}
else{
//Mobile Device
}https://stackoverflow.com/questions/69138018
复制相似问题