Dear @agraham,
Thank you very much for your valuable module, your B4A program works perfectly.
I have used same code from your post in my program.
Unfortunately, all times, MES.Haspermission returns false: Both entering to get the permission and after the permission has gotten.
The code perfectly opens permission dialog. Although Haspermission is false, the permission on this page is true.
Unfortunately, MsgboxAsync creates problems, hence I have deleted it.
The log is also supplied.
Please help me to solve this problem.
Thanks and regards.
Thank you very much for your valuable module, your B4A program works perfectly.
I have used same code from your post in my program.
Unfortunately, all times, MES.Haspermission returns false: Both entering to get the permission and after the permission has gotten.
The code perfectly opens permission dialog. Although Haspermission is false, the permission on this page is true.
Unfortunately, MsgboxAsync creates problems, hence I have deleted it.
The log is also supplied.
Please help me to solve this problem.
Thanks and regards.
B4X:
Dim SdkVersion As Int = device.SdkVersion
' Choose which permission to request in order to access external storgage
If SdkVersion < 30 Then
Log("SDK = " & SdkVersion & " : Requesting WRITE_EXTERNAL_STORAGE permission")
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted
Wait For activity_PermissionResult (Permission As String, Result As Boolean)
Log($"PERMISSION_WRITE_EXTERNAL_STORAGE = ${Result}"$)
Else
Log("SDK = " & SdkVersion & " : Requesting MANAGE_EXTERNAL_STORAGE permission")
Log("On Entry MANAGE_EXTERNAL_STORAGE = " & MES.HasPermission)
If Not(MES.HasPermission) Then
'MsgboxAsync("This app requires access to all files, please enable the option", "Manage All Files")
'Wait For Msgbox_Result(Res As Int)
Log("Getting permission")
MES.GetPermission
Wait For MES_StorageAvailable
Log("Permission gotten")
Log("On exit MANAGE_EXTERNAL_STORAGE = " & MES.HasPermission)
End If
End If
B4X:
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
SDK = 34 : Requesting MANAGE_EXTERNAL_STORAGE permission
On Entry MANAGE_EXTERNAL_STORAGE = false
Getting permission
** Activity (main) Resume **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Calling : MES_StorageAvailable
** Activity (main) Resume **
Permission gotten
On exit MANAGE_EXTERNAL_STORAGE = false