Android应用如何获得SIM状态

应用如何获得SIM状态:

    /*
     * SIM status
     */
    public String getSimState(){  
        TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);  
         int simState = mTelephonyManager.getSimState();
         
         switch (simState) {  

             case TelephonyManager.SIM_STATE_ABSENT:  
                 mString = "SIM ABSENT";  
                 break;  

             case TelephonyManager.SIM_STATE_NETWORK_LOCKED:  
                 mString = "SIM NETWORK LOCKED";  
                 break;  

             case TelephonyManager.SIM_STATE_PIN_REQUIRED:  
                 mString = "SIM PIN REQUIRED";  
                 break;  

             case TelephonyManager.SIM_STATE_PUK_REQUIRED:  
                 mString = "SIM PIN 2 REQUIRED";  
                 break;  

             case TelephonyManager.SIM_STATE_READY:  
                 mString = "SIM READY";  
                 break;  

             case TelephonyManager.SIM_STATE_UNKNOWN:  
                 mString = "UNKNOWN";  
                 break;  
         }  
         
         return mString;
    }  
    



你可能感兴趣的:(Android)