When I try to activate my app as device admin an click Activate this device admin app , I am sent back to the previous screen and the device admin is not activated.
Receiver in manifes:
<receiver
android:name=".MyDeviceAdminReceiver"
android:permission="android.permissions.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_policies" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
Receiver class:
public class MyDeviceAdminReceiver extends DeviceAdminReceiver
{
public void onEnabled(@NonNull Context context, @NonNull Intent intent)
{
Log.d("DeviceAdmin", "OnEnabled");
super.onEnabled(context, intent);
SharedPreferences.Editor defaultPrefEditor = PreferenceManager.getDefaultSharedPreferences(context).edit();
defaultPrefEditor.putBoolean(context.getString(R.string.pref_device_admin_status), true);
defaultPrefEditor.apply();
}
@Override
public void onDisabled(@NonNull Context context, @NonNull Intent intent)
{
Log.d("DeviceAdmin", "OnDisabled");
super.onDisabled(context, intent);
SharedPreferences.Editor defaultPrefEditor = PreferenceManager.getDefaultSharedPreferences(context).edit();
defaultPrefEditor.putBoolean(context.getString(R.string.pref_device_admin_status), false);
defaultPrefEditor.apply();
}
}
Found it!
android:permission="android.permissions.BIND_DEVICE_ADMIN"
I wrote permissions
when it should be permission
.
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.