Bob
Bob

Reputation: 21

StartLockTask() in Device Owner mode still allows escape with back button

I have installed my app as administrator first and after using an adb shell as a Device Owner. Then I start the lock mode with:

startLockTask();

Everything seems to work good and when I press menu' and home button an Android Toast tell me that the escape is not allow. The problem is that the long press of back button allow always to unlock() the app (as in pinned mode). Moreover when I startLockTask I notice an evident delay of application performace (the application lagging). I'm working with android 7 and Cat device. How can I solve these problems to get a full kiosk mode? I'm locking for a way to lock menu and recent app botton without restart the activity (as startLockTask do). Thank you.

Upvotes: 0

Views: 1730

Answers (1)

lukaspp
lukaspp

Reputation: 1149

In order to use a Device Policy controller and lock task you should add your application package to whitelisted locktask packages, using this:

    devicePolicyManager.setLockTaskPackages(
           deviceReceiver,new String[]{componentName.getPackageName()}); 

Then you should add in you locked app manifest, under application this:

    android:lockTaskMode="if_whitelisted"

Hope it helps.

Upvotes: 1

Related Questions