I have an Android device that is running a single application. This application starts on boot and is the only one the user shall be able to see.
But once this app is running, I would like to be able to launch another app by clicking a button on this "boot" app, in a way that this second app is launched in "kiosk" mode, so that the user cannot go back, cannot go home, cannot get any notification, and so on, until certain action is finished.
For this I am trying to follow the Google documentation for lock mode here.
But it is not clear for me, when it tells "DPC must allow apps..." this code should be placed in the initial app (the one on boot), or for the one I want to run in kiosk mode?.
Would appreciate a bit more detailed info on that.
The part when it tells:
// Set an option to turn on lock task mode when starting the activity.
val options = ActivityOptions.makeBasic()
options.setLockTaskEnabled(true)
// Start our kiosk app's main activity with our lock task mode option.
val packageManager = context.packageManager
val launchIntent = packageManager.getLaunchIntentForPackage(KIOSK_PACKAGE)
if (launchIntent != null) {
context.startActivity(launchIntent, options.toBundle())
}
I assume that is indeed to be placed on the "boot" app.
Yes, that part will reside in your boot app, which should work for you but you can also add the second apps packagename to the
DevicePolicyManager.setLockTaskPackages()
If you don't want to try that method as seen below:
private val YOUR_BOOT_APP_PACKAGE_NAME = "your.boot.app.packagename"
private val YOUR_SECOND_APP_PACKAGE_NAME = "your.second.app.packagename"
private val APP_PACKAGES = arrayOf(YOUR_BOOT_APP_PACKAGE_NAME, YOUR_SECOND_APP_PACKAGE_NAME)
mDevicePolicyManager.setLockTaskPackages(mAdminComponentName, APP_PACKAGES)