Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

broadcast action on permission change in android M

Tags:

does application gets any broadcast or any kind of alert when its permission setting is changed from Settings? I have got a scenario where we start some kind of logging when application starts and has got LOCATION GROUP permissions. But when user revokes this permission in between our application crashes. Not finding any way to stop the logging when user cancels it. This logging is from 3rd party library so we can not put any check permission check too in between.

like image 691
Sumit Shrivastava Avatar asked Sep 22 '15 13:09

Sumit Shrivastava


People also ask

What is broadcast permission?

During a session, meeting hosts can grant "hand-raising" privileges to participants. In Digital Samba, this functionality is known as "Request to Broadcast." This allows audience members to participate during your meetings by asking permission to broadcast their own streams and presentations.

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.

What is Read_phone_state permission?

READ_PHONE_STATE - You must ask the end user to grant this permission.) Allows read only access to the phone's state, and is used to determine the status of any ongoing calls. You need this permission so you can verify that your end user receives a phone call from Telesign. android.


1 Answers

does application gets any broadcast or any kind of alert when its permission setting is changed from Settings?

Not that is documented.

If the user revokes a permission that was previously granted to you, your process will be terminated. When you next run, you will wind up finding out about the permission change as part of checking for permissions.

If the user grants a permission that was previously denied, your process is not terminated. However, once again, when you call checkSelfPermission(), you will find out that you have access.

The lesson here is: do not cache permission lookup results. They seem to be fairly cheap calls, so just call checkSelfPermission() as needed.

If your targetSdkVersion is below 23, checkSelfPermission() will not help, but you should be getting bogus data rather than a SecurityException. In the case of location fixes, you should not get any locations if the user has revoked your location access permissions.

But when user revokes this permission in between our application crashes

I have not tried a scenario where a background service is running and the user revokes a permission. It should be terminating your process, and so you would find out about the permission change when your service runs for the next time. If you are finding that your process is not being terminated, that may be a sign of a bug in Android.

like image 122
CommonsWare Avatar answered Sep 23 '22 17:09

CommonsWare