本文介绍了如何找出一个特定的设备是否具有SIM硬件支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用基于SIM卡的硬件是否是present或不是在我的应用程序中调用和短信相关的功能。现在,一个初学者对这种将使用被检查手机类型的方法:

I wanted to disable features related to CALL and SMS in my application based on whether SIM hardware is present or not. Now a beginners approach towards this will be checking the Phone type using :

if (telephonyManager1.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)

如果为真,那么它的支持。

If true then its supported.

一切都很好,直到我遇到了索尼Tablet S的它只有对数据和信息SIM卡的支持。没有语音支持。因此,对于这个设备,我需要禁用只有通话功能,但继续与短信支持。 索尼平板电脑返回TelephonyManager.PHONE_TYPE_NONE,所以我不能老是用上面的方法。此外,

Everything was fine until i came across Sony Tablet S which has a SIM support only for Data and Messaging. No voice support. So for this device i need to disable only CALL feature but continue with SMS support. Sony tablet returns TelephonyManager.PHONE_TYPE_NONE so i can`t use the above methods. Also ,

telephonyManager1.getSimState();

返回1,即SIM_STATE_ABSENT这也是以防HTC Flyer的这对SIM硬件本身不支持的一样。

returns 1 i.e SIM_STATE_ABSENT which is also same in case of HTC FLYER which has no support for SIM hardware itself.

那么,有什么办法,我可以来知道SIM卡的硬件有没有(无论插入或SIM卡)?

So is there any way in which i can come to know if SIM hardware is there(irrespective of SIM card inserted or not) ?

推荐答案

使用

PackageManager pm = this.getPackageManager();
boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);

编辑:

尝试使用

TelephonyManager.getLine1Number()

如果返回null,那么你不会有电话功能。没有尝试过。给它一个镜头

If this returns null then you wont have telephony feature. Have not tried. give it a shot

这篇关于如何找出一个特定的设备是否具有SIM硬件支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 14:44