Hi ,
when my app start Android open the 'request permission access confirm box' and wait that I press OK to open the next form with the permission selection list.
The problem is that my app still running in background while this box is open and if I don't press OK quickly it crash because timeout.
My manifest.
Code I found to enable the access file permission.
Thanks in advance
Paolo
when my app start Android open the 'request permission access confirm box' and wait that I press OK to open the next form with the permission selection list.
The problem is that my app still running in background while this box is open and if I don't press OK quickly it crash because timeout.
My manifest.
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="3"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddPermission(android.permission.MANAGE_EXTERNAL_STORAGE)
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
Code I found to enable the access file permission.
B4X:
Dim pm As B4XPagesManager
pm.Initialize(Activity)
If FirstTime Then
MES.Initialize(Me, "MES")
End If
' get the device SDK version
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("Completato")
End If
End If
End Sub
Thanks in advance
Paolo