TL;DR How to make a phone call while using Activity.startLockTask()
?
I'm trying to setup a restricted environment on an Android device, i.e. what is usually called "Kiosk-Mode".
Official documentation can be found here: https://developer.android.com/work/cosu.html
The official way of doing this suggest to use Activity.startLockTask.
This works fine until you want to start other apps from within your Activity
which is in startLockTask()
mode.
Any activity that launches must not start on a new task stack otherwise the system blocks the launch intent, i.e. no Intent.FLAG_ACTIVITY_NEW_TASK
.
Some apps can just be launched, other seem to implicitly set this flag, but can be workedaround by using startActivityForResult(...)
which seems remove the NEW_TASK
flag. For apps that still don't work I could code my own replacement.
The real issue is the call application, which enforces a new task stack. Triggering a call initiated the call, doesn't show the call activity, but also puts a call notification in the status bar (which is not accessible in while using startLockTask()
.
In contrast to other apps the call app is also one that can't be replaced with a custom app...
DevicePolicyManager.html.setLockTaskPackages() has no effect on this behavior.
I tried to make start call intent under locked mode and this line pop up:
So I add
Managed to get the dialler out. Of course if I push the home button or back button, there's no way to get the dialler back... the recent button is still locked though. Receiving call works perfectly (all buttons are disabled)