I implemented below to unlock my application (this code only works for system applications, so I made my application as a system application)
TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
int state = manager.getSimState();
if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED || state == TelephonyManager.SIM_STATE_PUK_REQUIRED)
{
try {
@SuppressWarnings("rawtypes")
Class clazz = Class.forName(manager.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(manager);
if (it.supplyPin(simPin)) {
Toast.makeText(context,"SIM UnLocked",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context,"SIM UNLOCK FAILED",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}else{
Toast.makeText(context,"SIM is not Locked",Toast.LENGTH_LONG).show();
}
It works great for me, but now I need to implement the program or reset the SIM code programmatically, let me know if this is possible or not. if possible, how can this be realized?
source
share