0
我寫過這些代碼;禁用相機但不能正常工作
case R.id.button_camera:
if (gate == false) {
Toast.makeText(this, "enable camera", Toast.LENGTH_LONG).show();
devicePolicyManager. setCameraDisabled(demoDeviceAdmin, false);
}
else {
Toast.makeText(this, "disable camera", Toast.LENGTH_LONG).show();
devicePolicyManager. setCameraDisabled(demoDeviceAdmin, true);
}
break;
我已經採取了以下錯誤;
01-16 11:50:12.833: E/AndroidRuntime(799): FATAL EXCEPTION: main
01-16 11:50:12.833: E/AndroidRuntime(799): java.lang.IllegalStateException: Could not execute method of the activity
01-16 11:50:12.833: E/AndroidRuntime(799): at android.view.View$1.onClick(View.java:3597)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.view.View.performClick(View.java:4202)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.view.View$PerformClick.run(View.java:17340)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.os.Handler.handleCallback(Handler.java:725)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.os.Handler.dispatchMessage(Handler.java:92)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.os.Looper.loop(Looper.java:137)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-16 11:50:12.833: E/AndroidRuntime(799): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 11:50:12.833: E/AndroidRuntime(799): at java.lang.reflect.Method.invoke(Method.java:511)
01-16 11:50:12.833: E/AndroidRuntime(799): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-16 11:50:12.833: E/AndroidRuntime(799): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-16 11:50:12.833: E/AndroidRuntime(799): at dalvik.system.NativeStart.main(Native Method)
01-16 11:50:12.833: E/AndroidRuntime(799): Caused by: java.lang.reflect.InvocationTargetException
01-16 11:50:12.833: E/AndroidRuntime(799): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 11:50:12.833: E/AndroidRuntime(799): at java.lang.reflect.Method.invoke(Method.java:511)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.view.View$1.onClick(View.java:3592)
01-16 11:50:12.833: E/AndroidRuntime(799): ... 11 more
01-16 11:50:12.833: E/AndroidRuntime(799): Caused by: java.lang.SecurityException: Admin ComponentInfo{com.marakana.android.devicepolicydemo/com.marakana.android.devicepolicydemo.DemoDeviceAdminReceiver} did not specify uses-policy for: disable-camera
01-16 11:50:12.833: E/AndroidRuntime(799): at android.os.Parcel.readException(Parcel.java:1425)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.os.Parcel.readException(Parcel.java:1379)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.app.admin.IDevicePolicyManager$Stub$Proxy.setCameraDisabled(IDevicePolicyManager.java:1700)
01-16 11:50:12.833: E/AndroidRuntime(799): at android.app.admin.DevicePolicyManager.setCameraDisabled(DevicePolicyManager.java:1345)
01-16 11:50:12.833: E/AndroidRuntime(799): at com.marakana.android.devicepolicydemo.DevicePolicyDemoActivity.onClick(DevicePolicyDemoActivity.java:62)
我該如何解決?
我已經這樣做了。 – user1983122
@ user1983122,你把它放在設備管理節點內嗎? –
如果你說device-admin.xlm,答案是肯定的 – user1983122