Has anyone got task locking working in Android L? Could they share some details on how it works? I have seen the instructions below, but struggling to understand this.
At the moment I have made an App that I would like to run in kiosk mode. I have looked at making it a launcher App or using Surelock but the new task locking looks like it will be the best option in future.
I need to create a userdebug build of Android L? I have not built Android from source before, I started looking at making a build but I don't think the source for Android-L is available yet?
To set up a device owner, follow these steps:
Attach a device running an Android userdebug build to your development machine.
Install your device owner app.
Create a device_owner.xml file and save it to the /data/system directory on the device.
$ adb root
$ adb shell stop
$ rm /tmp/device_owner.xml
$ echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>">> /tmp/device_owner.xml
$ echo "<device-owner package=\"<your_device_owner_package>\"name=\"*<your_organization_name>\" />" >> /tmp/device_owner.xml
$ adb push /tmp/device_owner.xml /data/system/device_owner.xml
$ adb reboot
https://developer.android.com/preview/api-overview.html
Edit: More info
I tried rooting my device (Nexus 7) running the Android-L preview. I then put a device_owner.xml with my package name in data/system/. But it still does not work, islockTaskPermited() return false, and calling startLockTask() does nothing.
Taking Below Snip from Task Locking API
It is clear that startLockTask() api will be hv effect if device_owner.xml is present .
How do i check if my app is device owner ?
When you app is device owner , you app is Device Administrator option will be checked and checkbox will be gray out hence will not allow u to untick the checkbox.
You need to give system right while pushing device_owner.xml
Follow below steps :
Make a file device_owner.xml using below content, replace appropriate package name
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<device-owner package="com.your.packagename" name="Yourname" />
adb push device_owner.xml /data/system/device_owner.xml Reboot device.
from com.your.packagename
app call
startLockTask();
from your activity
Even if you do not have userdebug, you can test it by calling startLockTask
, without pushing any file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With