gpt4 book ai didi

android - 设备策略管理员无法检索设备策略

转载 作者:行者123 更新时间:2023-11-29 14:55:33 25 4
gpt4 key购买 nike

我正在尝试让设备策略管理器工作,但在尝试启用它时卡住了。在谷歌上搜索了很多,并且已经对这个错误变得激进了:

10-05 10:39:07.147: WARN/DeviceAdminAdd(144): Unable to retrieve device policy ComponentInfo{test.devadmin/test.devadmin.DeviceAdmin$MyDeviceAdminReceiver}
10-05 10:39:07.147: WARN/DeviceAdminAdd(144): android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{test.devadmin/test.devadmin.DeviceAdmin$MyDeviceAdminReceiver}

list :

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".DeviceAdmin" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".app.DeviceAdmin$Controller"
android:label="@string/activity_sample_device_admin">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<receiver android:name="MyDeviceAdminReceiver"
android:label="@string/app_label"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
</application>
</manifest>

设备管理.xml

<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<limit-password />
<watch-login />
<reset-password />
<force-lock />
<wipe-data />
</uses-policies>
</device-admin>

启用方法

    public void enable() {
if (!mDPM.isAdminActive(mDeviceAdmin)) {
Intent intent = new Intent(
DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
mDeviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Additional text explaining why this needs to be added.");
startActivityForResult(intent, REQUEST_ENABLE);
} else {
mDPM.lockNow();
}

Receiver 类与此处找到的基本相同:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.html

http://rootfs.wordpress.com/2010/09/09/android-make-your-application-a-device-administrator/

任何帮助或建议将不胜感激!

最佳答案

检查您的收件人姓名 <receiver android:name="MyDeviceAdminReceiver"

我想你忘了添加 .在接收者姓名之前:

<receiver android:name=".MyDeviceAdminReceiver"

关于android - 设备策略管理员无法检索设备策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7660367/

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