How to use Android-L preview Task Locking?

北城以北 提交于 2019-11-29 02:06:46

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 :

  1. Create device_owner.xml [make sure the app will be present before u push device_owner.xml ]
  2. Navigate to path in terminal where device_owner is present
  3. adb push device_owner.xml /sdcard/
  4. adb shell
  5. su
  6. cp /sdcard/device_owner.xml /data/system/
  7. cd /data/system/
  8. chown system:system device_owner.xml
  9. reboot

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!