How to find out whether a particular device has SIM Hardware support?

社会主义新天地 提交于 2019-12-04 11:00:14

问题


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.

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();

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

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


回答1:


Use

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

Edit:

Try using

TelephonyManager.getLine1Number()

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



来源:https://stackoverflow.com/questions/12001863/how-to-find-out-whether-a-particular-device-has-sim-hardware-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!