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.
@Sheikh Shuaib Ashraf Please make sure the PACKAGE_USAGE_STATS permisson has been added to
AndroidManifest.xml
.Thanks a lot sir.
Sir, how to check if the permission is granted
Thanks
Try getting the AppOpsManager service to check the permission's grant status.
Worked fine but it "AppOpsManager.CheckOpNoThrow" show depreciated method.
Now, will implement the pattern lock. if you suggest anything that will be highly appreciated
Thanks
Sorry for late reply. The
AppOpsManager.CheckOpNoThrow
command seems to be depreciated, you could useAppOpsManagerCompat.NoteOpNoThrow
instead.Sign in to comment