Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission changed callback in Android 6.0

I wonder if there is some way to being notified when user changes permission in app settings on Android 6.0. I was looking for this answer with no luck. Do you know if it is possible with broadcast receiver and some specific Intent? Or maybe there is some hack to achieve this?

like image 677
Aleksander Mielczarek Avatar asked Dec 10 '15 10:12

Aleksander Mielczarek


People also ask

How do I give permission to Android call?

Write the permission code in Android-Manifest. You need to write CALL_PHONE permission as given below: <uses-permission android:name="android. permission. CALL_PHONE" />

What is SYSTEM_ALERT_WINDOW permission?

A flutter plugin to show Truecaller like overlay window, over all other apps along with callback events. Android Go or Android 11 & above, this plugin shows notification bubble, in other android versions, it shows an overlay window.

How do I check if permission is granted Android?

checkSelfPermission(activity, Manifest. permission. X) checks if any permission is already granted, if you check out other answers they do the same, and rest of the code asks for the permissions not granted.


2 Answers

You can keep track of this by using the AlarmManager to periodically check for the permissions your're interested in (for example every 30 seconds) and compare it to the value you saw the last time (saved in SharedPreferences for example). In the worst case you won't get updates within the timer interval, however it should be very unlikely that the user changes a permission multiple times within a short time interval.

Keep in mind that you have to start the periodical checks when the device boots up (android.intent.action.BOOT_COMPLETED).

like image 28
Thomas Wanschik Avatar answered Nov 03 '22 02:11

Thomas Wanschik


according to this answer, there is no any broadcast/event that you can intercept when permission revoked from the settings screen by the user.

but the "good" news, in assumption that it's your concern - your process will be terminated automatically by the system if there will be any changes to the permission status while your app process was alive

like image 50
Tal Kanel Avatar answered Nov 03 '22 03:11

Tal Kanel