3

How to find programatically selected option for the microphone permission is "Ask Every Time" (Only this time)?

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.RECORD_AUDIO);

Above code will return true if permission granted with "Allow only while using the app" or "Ask Every Time" (Only this time).

But I wanted to differentiate above two type of permission.

[Update] Use case :- If application granted with "One time permission" and moving application to background for more than 20 seconds results one time permission is revoked. Once permission revoked application restarts the activity. So, I wanted to give alert (toast or dialog) when user selected one time permission.

Ranjit
  • 833
  • 8
  • 15
  • Why you want to differentiate above two type of permission.If your app already follows best practices when it requests runtime permissions, you don't need to change your app to support one-time permissions. – Leon Oct 30 '20 at 10:17
  • If application granted with "One time permission" and moving application to background for more than 20 seconds. one time permission is revoked. Once permission revoked application restarts the activity (https://stackoverflow.com/questions/52480339/activity-restart-every-time-when-disable-permission-from-setting). So, I wanted to give alert (toast for dialog) when user selected one time permission. This is one of the use case I wanted to achieve. Is it possible to differentiate? – Ranjit Oct 30 '20 at 10:34
  • 1
    I search it, Google do not provide any related api for one time permission. – Leon Nov 02 '20 at 01:16

1 Answers1

2

There is no way to know what the user selected for permission granting aside from using shouldShowRequestPermissionRationale. You should not be worried about what they selected and should be worried about how to handle when you dont have permission and tell the user why you need it or what happens if they dont grant it

tyczj
  • 71,600
  • 54
  • 194
  • 296