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) ?
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