Android 6 permission changes - what happens if we try and use a feature before permission is granted?

I saw this blog post yesterday which got me thinking about this matter:

https://coronalabs.com/blog/2016/02/23/breaking-change-android-6-and-device-ids/

I don’t have a Marshmallow device to hand to test this, so I’m hoping someone out there already knows the answer to this.  

Let’s ay my app uses the camera. What would happen if I tried to use the camera in my app WITHOUT calling something like this:

local permissionOptions = { appPermission = "android.permission.CAMERA", urgency = "Critical", listener = appPermissionsListener, rationaleTitle = "Camera required", rationaleDescription = "This app needs the camera so you can take your picture", settingsRedirectTitle = "Alert", settingsRedirectDescription = "Without the ability to access your device's camera, the app can't function properly. Please grant camera access within Settings." } native.showPopup( "requestAppPermission", permissionOptions )

Will Android detect that I’m trying to use a feature which has not had permissions requested and automatically bring up a permission request popup? Or will it just fail to use the camera?  

Also, what happens if the user rejects the permission but then changes their mind? Is there a way to manually go and turn on the permission, or do we need to put extra options in our app to allow them to do this (e.g. in a settings screen).

Hi Alan QuizTix,

When we upgraded Android to target API Level 23, we tried our best to mitigate the potential breaking changes to existing apps by requesting certain permissions automatically where we can.

In our release notes for build 2016.2828, we highlight which Corona SDK APIs will automatically try to request dangerous permissions if they aren’t already granted. These include:

In addition to these, if you app uses Expansion Files, it will request Storage permission when you app launches if needed.

The default behavior of these automatic permission requests is similar to that of iOS. Moreover, if the user denies them, the app will try to carry on with the permission denied. Unlike iOS, if the permission is denied, repeated calls to one of the above APIs will continue to request the denied permission.

If you need more control over what happens with permission requests, then you should be using the requestAppPermission popup as you’ve demonstrated above.

There isn’t a way for the programmer to manually grant or deny permission access. It’s up to the user to grant app permissions.

If a user wants to configure permission access outside of request permission dialogs, they can do so in Settings -> Apps -> [App Name] -> Permissions.

In Corona SDK, the only way to redirect users to the Settings app to configure permissions themselves is if they select the “Never Ask Again” checkbox on a permission request with “Critical” urgency.

For Corona Enterprise, you can do this redirection to Settings through a code snippet like this:

Intent intent = new Intent(android.provider.Settings.ACTION\_APPLICATION\_DETAILS\_SETTINGS); intent.setData(Uri.fromParts("package", activity.getPackageName(), null)); activity.startActivity(intent);

Thanks Ajay, that’s all been very helpful. With regards to manually granting permissions, I meant from the user’s perspective rather than the developer’s, but you’ve covered that too  :slight_smile:

Hi Alan QuizTix,

When we upgraded Android to target API Level 23, we tried our best to mitigate the potential breaking changes to existing apps by requesting certain permissions automatically where we can.

In our release notes for build 2016.2828, we highlight which Corona SDK APIs will automatically try to request dangerous permissions if they aren’t already granted. These include:

In addition to these, if you app uses Expansion Files, it will request Storage permission when you app launches if needed.

The default behavior of these automatic permission requests is similar to that of iOS. Moreover, if the user denies them, the app will try to carry on with the permission denied. Unlike iOS, if the permission is denied, repeated calls to one of the above APIs will continue to request the denied permission.

If you need more control over what happens with permission requests, then you should be using the requestAppPermission popup as you’ve demonstrated above.

There isn’t a way for the programmer to manually grant or deny permission access. It’s up to the user to grant app permissions.

If a user wants to configure permission access outside of request permission dialogs, they can do so in Settings -> Apps -> [App Name] -> Permissions.

In Corona SDK, the only way to redirect users to the Settings app to configure permissions themselves is if they select the “Never Ask Again” checkbox on a permission request with “Critical” urgency.

For Corona Enterprise, you can do this redirection to Settings through a code snippet like this:

Intent intent = new Intent(android.provider.Settings.ACTION\_APPLICATION\_DETAILS\_SETTINGS); intent.setData(Uri.fromParts("package", activity.getPackageName(), null)); activity.startActivity(intent);

Thanks Ajay, that’s all been very helpful. With regards to manually granting permissions, I meant from the user’s perspective rather than the developer’s, but you’ve covered that too  :slight_smile: