Locking screen when app is in LockTask mode

  • Replies:0
Novak Nole
  • Forum posts: 1

Feb 18, 2017, 2:09:30 PM via Website

Hello,

I noticed specific behavior that I can reproduce on all devices (Android 6) that I have and is related to running application in lock task mode (not pinning).

First, with device owner app, I enable another app to run in Lock Task Mode. As soon as application enters lock task mode, screen can not be locked. What I tried:
- Power button
- Auto lock on sleep
- Programmaticaly with DevicePolicyController lockNow method, it executes but nothing happens.

Is there any way to achieve screen lock when an application is in lock task mode, but in graceful manner?

I was able to "fix" the "problem", but I do not like my solution. Basically, in my device owner app, I added broadcast receiver to list for "android.intent.action.SCREEN_OFF" and "android.intent.action.SCREEN_ON" and send those notifications to related activity, which will leave lock task mode when screen is off and force lock screen, also vise versa. So this works, but it is terrible hack.

Regards,
Novak

Reply