Usage access permission

Sheikh Shuaib Ashraf 21 Reputation points
2021-06-23T10:48:57.403+00:00

I am building an 'App locker' App in which I've displayed all the User Apps and System App in Listview, and I've added a toggle button to this listview, on turning (toggle button) ON/OFF, I want to lock/unlock the app of the phone. And lock is based on Pattern.

Whenever the App, which I locked, there should appear a Pattern Lock for Unlocking the app.

For this I need to grant my App USAGE ACCESS.
How to achieve that

Thanks!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,951 Reputation points
    2021-06-24T03:12:27.54+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Whenever the App, which I locked, there should appear a Pattern Lock for Unlocking the app. For this I need to grant my App USAGE ACCESS.

    The PACKAGE_USAGE_STATS is a dangerous permission which cannot be requested in a pop-up dialog at runtime such as requesting the READ_EXTERNAL_STORAGE permission. We can only guide the user to open the Apps with strong textUsage Access setting page.

    Here is the code to open the Setting Application page

       StartActivity(new Intent(Android.Provider.Settings.ActionUsageAccessSettings));  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful