简体   繁体   中英

Android does't show my app in device admin apps list

I need to put my application in lock task mode. In order to do this I have to make my app as a device admin app. I have followed all the guides from the documentation. But Android system does not show my app in device admin apps list so that I cannot activate my app as a device admin. An application named "Hidden Device Admin Detector" shows my app as a device admin app, but the OS does not. Here is my AndroidManifest.xml:

<receiver
        android:name="infrastructure.XDeviceAdminReceiver"
        android:description="@string/app_name"
        android:label="@string/app_name"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data
            android:name="android.app.device.admin"
            android:resource="@xml/device_admin_receiver" />

        <intent-filter>
            <action 
            android:name="android.intent.action.DEVICE_ADMIN_ENABLED" />
        </intent-filter>
    </receiver>

Here is my DeviceAdminReceiver subclass:

public class XDeviceAdminReceiver extends DeviceAdminReceiver
{
    @Override
    public void onEnabled(Context context, Intent intent) {

    }
}

And here is the inside of device_admin_receiver.xml

<?xml version="1.0" encoding="utf-8"?>
<device-admin>
    <uses-policies>
        <limit-password />
        <watch-login />
        <reset-password />
        <force-lock />
        <wipe-data />
        <expire-password />
        <encrypted-storage />
        <disable-camera />
        <disable-keyguard-features />
    </uses-policies>
</device-admin>

Try to uninstall your app to ensure it is device admin and install it on another device. Be sure the device admin permission is granted. Maybe your app stored on external storage. if it is, move it to internal shared storage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM