Skip to content
Advertisement

Xamarin MAUI No Active Admin Security Exception (Kiosk mode app)

I’m trying to run an app on the android emulator with full kiosk mode. So I wrote a DeviceAdminReceiver:

JavaScript

Here’s the MainActivity:

JavaScript

And finally here’s the AndroidManifest.xml:

JavaScript
>

The problem is that this line in MainActivity throw this exception:

JavaScript

I already have a device_admin.xml in resources/xml with a device-admin tag, does it need more configuration? Or is the issue else where? Or maybe i’m instanciating two difference admin receiver?

Note: I already did the procedure to allow this app as device admin on the emulator and run the command via android debug bridge setting it as device owner:

JavaScript

Advertisement

Answer

Can you ensure that you are actually registering your BroadcastReceiver with attributes on the class instead of modifying the AndroidManifest.xml manually. I think what is throwing you off is that if you don’t register the receiver, it will get named as <md5 sum>.AdminReceiver. However, when you are adding the reciever as .AdminReceiver in the AndroidManifest.xml, then Android will inflate that as <package name>.AdminReciever. So your AdminReceiver won’t get called.

So try something like:

JavaScript

Then you should remove your entry in the manifest.

If you need to filter specific intents, you can also add the [IntentFilter] attribute to add those, but it shouldn’t be necessary for device admin.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement