Android 如何检查设备是否支持SMS?
我想在没有SIM卡插槽的平板电脑上以编程方式禁用SMS功能 我试过这个:Android 如何检查设备是否支持SMS?,android,sms,Android,Sms,我想在没有SIM卡插槽的平板电脑上以编程方式禁用SMS功能 我试过这个: if (context.getSystemService(Context.TELEPHONY_SERVICE) != null) { // SMS features: enable } else { // SMS features: disable } 但是在我的NVidia Shield平板电脑K1上(没有sim卡插槽)context.getSystemService(context.TELEPHONY
if (context.getSystemService(Context.TELEPHONY_SERVICE) != null)
{
// SMS features: enable
}
else
{
// SMS features: disable
}
但是在我的NVidia Shield平板电脑K1上(没有sim卡插槽)context.getSystemService(context.TELEPHONY_SERVICE)
返回一些信息,看起来我有电话服务
我的代码有什么问题?在这种情况下,我不认为检索
TelephonyManager
的getSystemService()
必须返回null
检查电话功能的官方方法是在PackageManager
上调用hasSystemFeature(PackageManager.FEATURE\u电话)
,您可以通过调用getPackageManager()
来获取
我已经掸掉了NVIDIA屏蔽K1上的灰尘,我从该设备上的hasSystemFeature(PackageManager.FEATURE_TELEPHONY)获得了
false
。如果给定的功能不可用,getSystemService不会返回null。我不知道你为什么认为它会,文档中没有任何内容表明它会。可能是重复的