Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Granted Runtime permission not being honored
Started by Alan PlantPot Jan 25 2017 02:11 PM

- - - - -
1 reply to this topic
runtime permission storage android

Best Answer Alan PlantPot , 25 January 2017 - 03:13 PM

I found the cause, which I'm embarrassed to say was similar to when I had this issue on Android <6.0.
 
It’s because I had this in my manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion=”24" tools:replace="android:maxSdkVersion"/>

and the device was running sdk version 25.

 

Changing the 24 to 25 fixed the problem.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 928 posts
  • Corona SDK

On Android 6.0+, we’re checking for the storage permission (or requesting it if needed). It’s coming back saying it is granted, but then the media.save call fails saying the permission is not granted.

 

I'm printing out to make sure, and this is the sequence:

call isStoragePermissionGranted( system.getInfo( "grantedAppPermissions" ) )

table: 0xca960ee0 {
  [1] => "android.permission.INTERNET"
  [2] => "Storage"
  ...plus others
}

call media.save
I/Corona(15340): ERROR: Saving Images requires access to the device's Storage!
I/Corona(15340): Ensure that your app is using the "android.permission.WRITE_EXTERNAL_STORAGE" permission.

It says right there in the system.getInfo( "grantedAppPermissions" )  call that the permission is granted, but then when it comes to calling media.save, it immediately throws an error saying the permission is not granted.

 

How is this possible?

 

If we go into the settings app, it also shows the Storage permission as being granted. Could it maybe be that Corona is only checking for "android.permission.WRITE_EXTERNAL_STORAGE" before trying to save, and not the "Storage" permission group?

 

 

Edit: I tried following some advice from Corona dev Scott Harrison, to change “Storage” to “android.permission.WRITE_EXTERNAL_STORAGE”. For some reason we then get the Corona error before we even try and save. It now shows the error when we call native.showPopup( "requestAppPermission", options )



[TOPIC: post.html]
#2

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 928 posts
  • Corona SDK

  Best Answer

I found the cause, which I'm embarrassed to say was similar to when I had this issue on Android <6.0.
 
It’s because I had this in my manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion=”24" tools:replace="android:maxSdkVersion"/>

and the device was running sdk version 25.

 

Changing the 24 to 25 fixed the problem.




[topic_controls]
[/topic_controls]