gpt4 book ai didi

java - Android 以编程方式设置/更改/删除锁定屏幕 PIN、密码或解锁图案

转载 作者:行者123 更新时间:2023-12-01 14:13:47 24 4
gpt4 key购买 nike

我正在开发一个 Android 项目,该项目用于使用密码保护 Android 设备。为此,我必须以编程方式设置密码。使用引用user device administration api还有这个example但它抛出错误(如下):

08-18 02:12:26.888: W/dalvikvm(2600): threadid=1: thread exiting with uncaught       exception (group=0x40a401f8)
08-18 02:12:26.888: E/AndroidRuntime(2600): FATAL EXCEPTION: main
08-18 02:12:26.888: E/AndroidRuntime(2600): java.lang.RuntimeException: Unable to start activity ComponentInfo{dilli.passwordtest/dilli.passwordtest.MainActivity}: java.lang.SecurityException: No active admin ComponentInfo{dilli.passwordtest/dilli.passwordtest.MainActivity}
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.os.Handler.dispatchMessage(Handler.java:99)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.os.Looper.loop(Looper.java:137)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread.main(ActivityThread.java:4429)
08-18 02:12:26.888: E/AndroidRuntime(2600): at java.lang.reflect.Method.invokeNative(Native Method)
08-18 02:12:26.888: E/AndroidRuntime(2600): at java.lang.reflect.Method.invoke(Method.java:511)
08-18 02:12:26.888: E/AndroidRuntime(2600): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-18 02:12:26.888: E/AndroidRuntime(2600): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-18 02:12:26.888: E/AndroidRuntime(2600): at dalvik.system.NativeStart.main(Native Method)
08-18 02:12:26.888: E/AndroidRuntime(2600): Caused by: java.lang.SecurityException: No active admin ComponentInfo{dilli.passwordtest/dilli.passwordtest.MainActivity}
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.os.Parcel.readException(Parcel.java:1327)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.os.Parcel.readException(Parcel.java:1281)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.admin.IDevicePolicyManager$Stub$Proxy.setPasswordQuality(IDevicePolicyManager.java:761)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.admin.DevicePolicyManager.setPasswordQuality(DevicePolicyManager.java:292)
08-18 02:12:26.888: E/AndroidRuntime(2600): at dilli.passwordtest.MainActivity.onCreate(MainActivity.java:24)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.Activity.performCreate(Activity.java:4465)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-18 02:12:26.888: E/AndroidRuntime(2600): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-18 02:12:26.888: E/AndroidRuntime(2600): ... 11 more

我对此没有明确的说明。所以,请有 friend 帮帮我吧。提前致谢。

最佳答案

Caused by: java.lang.SecurityException: No active admin ComponentInfo{dilli.passwordtest/dilli.passwordtest.MainActivity}

为了修改设备管理员设置,您的应用必须获得设备管理员用户的批准。您需要使用适当的策略实现 DeviceAdminReceiver,并且用户必须进入“设置”中的安全屏幕并将您的应用程序激活为设备管理应用程序。

关于java - Android 以编程方式设置/更改/删除锁定屏幕 PIN、密码或解锁图案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18293208/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com