【发布时间】:2017-12-07 15:57:47
【问题描述】:
我想在没有 SIM 卡插槽的平板电脑上以编程方式禁用 SMS 功能。
我试过这个:
if (context.getSystemService(Context.TELEPHONY_SERVICE) != null)
{
// SMS features: enable
}
else
{
// SMS features: disable
}
但是在我的 NVidia Shield Tablet K1(没有 sim 卡插槽)context.getSystemService(Context.TELEPHONY_SERVICE) 上返回了一些东西,看起来我有电话服务。
我的代码有什么问题?
【问题讨论】:
-
如果给定功能不可用,getSystemService 不会返回 null。我不知道你为什么认为它会,文档中没有任何东西说它会。