リフレクションを使用して、デバイスの画面を無効に設定しています。キーパッドをdisabled.myとして設定します。アンドロイドのバージョンが4.4.2.whileの場合、例外が発生します。java.lang.reflect.InvocationTargetExceptionjava.lang.SecurityException:LockSettingsWrite:ユーザー10096も現在のプロセスもandroid.permission.ACCESS_KEYGUARD_SECURE_STORAGEを持っていません。反射を使用してデバイスの画面のロックを解除する
私は私のコードこのエラーはキットカットで発生するのはなぜか
try{
Class lockPatternUtilsCls = Class.forName("com.android.internal.widget.LockPatternUtils");
Constructor lockPatternUtilsConstructor = lockPatternUtilsCls.getConstructor(new Class[]{Context.class});
Object lockPatternUtils = lockPatternUtilsConstructor.newInstance(ChangeDeviceLockMode.this);
Method clearLockMethod = lockPatternUtils.getClass().getMethod("clearLock", boolean.class);
clearLockMethod.setAccessible(true);
Method setLockScreenDisabledMethod = lockPatternUtils.getClass().getMethod("setLockScreenDisabled", boolean.class);
setLockScreenDisabledMethod.setAccessible(true);
clearLockMethod.invoke(lockPatternUtils, false);
setLockScreenDisabledMethod.invoke(lockPatternUtils, true);
Toast.makeText(ChangeDeviceLockMode.this,"none", Toast.LENGTH_LONG).show();
}catch(Exception e){
System.err.println("An InvocationTargetException was caught!");
Throwable cause = e.getCause();
Toast.makeText(ChangeDeviceLockMode.this,"none"+e, Toast.LENGTH_LONG).show();
}
Toast.makeText(ChangeDeviceLockMode.this,"Yupiee!!! Password changed successfully to swipe", Toast.LENGTH_LONG).show();
}
コードがJellybeanで完全に動作します? –
私の要件がkitkatに固有であるために試したことはありません – tanmeet