我已经实现了以下解锁我的应用程序(此代码仅适用于系统应用程序,因此我已将我的应用程序作为系统应用程序完成)
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 PIN,如果可能,请告诉我。如果可能,我该如何实现呢?
答案 0 :(得分:3)
String ussdCode = "**04*"+oldPin+"*"+newPin+"*"+newPin+"#";
startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));