How to determine if a PIN is required to unlock sim?

In the android settings "Settings / Location and Security Settings" there is an option "SIM Lock".

You must enter the PIN code after downloading, if set.

Is there any software method to determine if I need a PIN? (not the current state of sim, but the value of the installation parameter ex: true / false)

+3
source share
2 answers

You can use the following class: TelephonyManager http://developer.android.com/reference/android/telephony/TelephonyManager.html

; Context.getSystemService(Context.TELEPHONY_SERVICE)

TelephonyManager manager = (TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE);
int state = manager.getSimState();
if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED || state == TelephonyManager.SIM_STATE_PUK_REQUIRED)
{
         //PIN/PUK is required
}

, :

TelephonyManager tm = 
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
       Class clazz = Class.forName(tm.getClass().getName());
       Method m = clazz.getDeclaredMethod("getITelephony");
       m.setAccessible(true);
       ITelephony it = (ITelephony) m.invoke(tm);
       if(it.isSimPinEnabled())
       {
                //This should work;
       }
+1

getSimLockEnabled false , .

. fooobar.com/questions/1798944/... .

0

All Articles