Search code examples
androidandroid-screen-pinning

How to pin an app without a dialog android


I am having trouble programmatically pinning an application in android without a dialog coming up asking the user if they would like to use screen pinning.

I am currently calling startLockTask () to lock the application.

The android documentation states that we need to use setLockTaskPackages to pin an app without asking the user's permission.

However, I'm not sure how to call this. I have made the application an administrator but I don't know where to go from here.

Any help would be awesome!


Solution

  • If you do not want the user to see the dialog box, your application has to be a device owner.

    You mentioned that your application is device admin, which is not sufficient.

    Any packages that shares uid with an allowed package will also be allowed to activate lock task. This function can only be called by the device owner.

    Here is the api documentation from google