简体   繁体   中英

How to Reset Android User Permissions Programatically in Java

I am trying to reset the android permissions defined by the user through a java program.

this is the part of android.webkit API and i found out on- GeolocationPermissions.Callback

Although there are a lot of android permissions that user may define in AndroidManifest.xml.So how do i reset all the permissions of android device in Java ? Is there any common way to do that?

Thanks in Advance.

In short, I don't think this is possible.

From what I have understood, you are referring to the new permission model (Runtime Permissions) introduced in Marshmallow and by "reset" you want user to grant it to you.

Runtime Permissions is a step to give users full control over the permissions used by the apps. Apps can only request for the permissions but cannot change it programmatically without any user interaction.

The solution here is to ask for the permission and check if user has granted it or not. If not, explain him about why you need that specific permission.

For more read:

(Correct me if I'm wrong / misunderstood the question. You can edit the question with more details.)

There's this API

((ActivityManager)context.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData();

Permits an application to erase its own data from disk. This is equivalent to the user choosing to clear the app's data from within the device settings UI. It erases all dynamic data associated with the app -- its private data and data in its private area on external storage -- but does not remove the installed application itself, nor any OBB files. It also revokes all runtime permissions that the app has acquired , clears all notifications and removes all Uri grants related to this application.

However, this api will force close your app. More info in this answer: https://stackoverflow.com/a/29197259/5673746

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM