How to use Android-L preview Task Locking?

前端 未结 2 410
走了就别回头了
走了就别回头了 2020-12-15 11:20

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.

相关标签:
2条回答
  • 2020-12-15 11:42

    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

    0 讨论(0)
  • 2020-12-15 11:50

    Taking Below Snip from Task Locking API

    enter image description here

    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.

    enter image description here

    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
    0 讨论(0)
提交回复
热议问题