Activate Button is disabled in Device Admin Screen in android

50 Views Asked by At

I have added following receiver in AndroidManifest

<receiver android:name=".app.DeviceAdmin"
    android:label="@string/device_admin_label"
    android:description="@string/device_admin_description"
    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>

In device_admin xml,

<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
    </uses-policies>
</device-admin>

In my class which extends ReactContextBaseJavaModule,

Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
            intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, compName);
            reactAppContext.startActivityForResult(intent, ENABLE_ADMIN_CODE,null);

I could able to launch Device Admin screen from my application. But Activate button is disabled. And other two buttons such as Cancel and Uninstall is not working. Suppose if I click android back button then immediately Activate button is enabled and all buttons are working fine. But at the initial launch its not working properly. Can anyone help on this.

0

There are 0 best solutions below