Java Android获取以编程方式解锁SIM卡的尝试次数
我通过这些线路通过我的应用程序动态解锁SIM PINJava Android获取以编程方式解锁SIM卡的尝试次数,java,android,gsm,telephony,Java,Android,Gsm,Telephony,我通过这些线路通过我的应用程序动态解锁SIM PIN TelephonyManager manager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); int state = manager.getSimState(); if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED || state == TelephonyManager.SIM_STATE_
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();
}
现在,我想知道已经有多少次尝试解锁SIM卡,比如默认SIM PIN/PUK解锁器,显示还有两次尝试。如果有任何可能性,请告诉我。如果sim解锁失败,只需创建一个从3到0计数的整数
int=3
}否则{
Toast.makeTextcontext,SIM解锁失败,Toast.LENGTH\u LONG.show
尝试-;
}
可能更实际的做法是将尝试计数器移动到静态的某个位置,以便跟踪和维护。将其保留在我假设的方法中并没有多大用途,因为它似乎超出了单次传递方法的范围。当通过其他应用程序进行尝试时,这不起作用。基本上,我想从SIM卡上获得这个值,如果它存在的话。嗯,做了一些研究,但我找不到其他选择。你找到了解决方案吗?没有直接的方法,你可以在SharedReferences中计算尝试次数