I don't know if it's because it's late and my brain is not working at peak, but I'm having a hard time with this puzzle, and maybe someone can come up with a solution.
Basically, I don't want to overload the user asking for a bunch of permissions the first time they run the app. So, I would rather wait until they actually need a particular permission, then ask for it.
But I also want to explain to the user why my app needs that permission, so they wont be confused with a cryptic "Allow MyApp to access photos, media, and files on your device?" prompt that seems more dangerous then what I need it for.
There is also a few different parts of my app that need Read_External_Storage permission, so I wanted to create a single Sub that will do all the above and return "True" if permission was granted, or False if not.
Here is what I have so far and the problem seems to be because I have multiple wait for's:
Basically, I don't want to overload the user asking for a bunch of permissions the first time they run the app. So, I would rather wait until they actually need a particular permission, then ask for it.
But I also want to explain to the user why my app needs that permission, so they wont be confused with a cryptic "Allow MyApp to access photos, media, and files on your device?" prompt that seems more dangerous then what I need it for.
There is also a few different parts of my app that need Read_External_Storage permission, so I wanted to create a single Sub that will do all the above and return "True" if permission was granted, or False if not.
Here is what I have so far and the problem seems to be because I have multiple wait for's:
B4X:
Sub cmdSoundPick_Click
'allows user to pick a notification sound
Wait for (CheckReadStoragePermission) Complete (Result As Boolean)
If Result = False Then Return 'exit if no permission
rm.ShowRingtonePicker("rm", Bit.Or(rm.TYPE_RINGTONE, Bit.Or(rm.TYPE_ALARM,rm.TYPE_NOTIFICATION)), False, cmdSoundPick.tag)
End Sub
Sub CheckReadStoragePermission As ResumableSub
If Starter.rp.Check(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE) = False Then
MsgboxAsync("In order for this app to play a built-in sound on your phone, it needs 'Read-Only' access to your 'Media'. The following screen will ask for that permission. If you deny this permission, then you will not be able to select a custom sound.","Sound Permission")
Wait For MsgBox_Result (Result As Int)
Wait for (AskReadStoragePermission) Complete (Result As Boolean) '<=========== get "Declaration does not match previous one" error
Return Result
Else
Return True
End If
End Sub
Sub AskReadStoragePermission As ResumableSub
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Return Result
End Sub
Last edited: