How can I check whether the Sim Card is available in an android device?

前端 未结 3 1635
-上瘾入骨i
-上瘾入骨i 2020-11-27 13:58

I need help checking whether a device has a sim card programatically. Please provide sample code.

3条回答
  •  执念已碎
    2020-11-27 14:36

    You can check with the below code :

    public static boolean isSimSupport(Context context)
        {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);  //gets the current TelephonyManager
            return !(tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT);
    
        }
    

提交回复
热议问题