I'm attempting to use "Lock Task mode", as described on https://developer.android.com/work/cosu.html
My goal is to have a single app running in a "kiosk mode", so that the user cannot leave the app.
I'm using Google's "Test DPC" app from Google Play as the DPC, which I have made the owner of the device via: adb shell dpm set-device-owner com.afwsamples.testdpc/.DeviceAdminReceiver
.
It all works really well at keeping a trivial app (which calls startLockTask()
) in kiosk mode. (I have added this trivial app to Test DPCs list of apps which are allowed to use "Lock Task mode".)
The problem is that if a user holds the back button, they escape "Lock Task mode" while displaying a confusing toast of "App is pinned: unpinning is not allowed on this device".
Is there a way of stopping this escape mechanism?
Update: The problem occurs on an Asus P00A with Android 7, but does not occur on an Android P00C with Android 6.
onBackPressed()
to be called. It's starting to look like it's an ASUS-specific "feature" rather than an Android issue. – Feast