Since Android 11, there has been a system feature where it resets app permissions after a certain amount of time has passed and you haven’t used the app.
I know you can turn it off on most apps, by the user itself like the screenshot below :
and also it seems to turn back on when there are app or system updates.
How can I disable this function in my app by code or sth else?
2
Answers
Well, I doubt there is an easy way.
If your app is a device policy controller, it will not be set to hibernation (System exemptions from hibernation) or, if your app is a default handler for messages, phone, browser etc.
What you can do, is to ask the user to disable auto revoke for your app. But you might have to do that after updates as well, if the system resets this privilege on your app (so your problem won’t be solved).
The permissions you request in your app manifest (
android:required="true"
) should never be revoked. But of course you cannot request every kind of permission that way. Some need to be requested explicitly.Apps using background services are whitelisted automatically as stated here. So you can declare a background service, if this is appropriate for you. But if there is nothing to be done, I could imagine, that the system removes your app from whitelist. (I didn’t test all of it)
If you see this post you can also try
and this in your manifest:
But I actually doubt it works.
i found article for your subject. It’s says,
Link to the article
You can examine this if you want. I hope it helps you.