I am running the latest android (29) my manifest target is 28. This is a B4xPages app.
The goal is to write 1 file to an external directory so the user can access it with other apps. I would like it to work with phones/tablets that are up to 3 or 4 years old.
I tried using FileProvider but it just seems to return File.DirInternal.
File.DirDefaultExternal works but says I should use RuntimePermissions.GetSafeDirDefaultExternal.
I am trying that with CheckAndRequest but it doesn't work. CheckAndRequest DOES WORK with other permissions.
This code:
Never returns.
The following is written to the manifest:
This code in MAIN fires:
but control never returns to my routine.
In debug, if I put a break on
the code in MAIN (
If I use:
It always runs the code inside the If.
I looked here (along with several other places) but didn't see anything useful.
Perhaps I am missing something obvious?
I'm running on a Pixel 3 XL Android Version 10. Build number is QQ3A.200805.001
Here is my manifest in case it is releveant:
As always thanks for your help.
The goal is to write 1 file to an external directory so the user can access it with other apps. I would like it to work with phones/tablets that are up to 3 or 4 years old.
I tried using FileProvider but it just seems to return File.DirInternal.
File.DirDefaultExternal works but says I should use RuntimePermissions.GetSafeDirDefaultExternal.
I am trying that with CheckAndRequest but it doesn't work. CheckAndRequest DOES WORK with other permissions.
This code:
B4X:
Dim RP As RuntimePermissions
RP.CheckAndRequest(RP.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult(Permission As String, AskResult As Boolean)
The following is written to the manifest:
B4X:
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
B4X:
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub
In debug, if I put a break on
Wait For Activity_PermissionResult(Permission As String, AskResult As Boolean)
thenthe code in MAIN (
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
) never fires and the entire app hangs.If I use:
B4X:
If Not(RP.Check(RP.PERMISSION_WRITE_EXTERNAL_STORAGE)) Then
RP.CheckAndRequest(RP.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult(Permission As String, AskResult As Boolean)
.
.
.
End IF
I looked here (along with several other places) but didn't see anything useful.
Perhaps I am missing something obvious?
I'm running on a Pixel 3 XL Android Version 10. Build number is QQ3A.200805.001
Here is my manifest in case it is releveant:
B4X:
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)'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-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
'Added Kim 9/9/20
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.VIBRATE")
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.hardware.camera")
'Added Kim 8/9/20
AddPermission(android.permission.BLUETOOTH)
AddPermission(android.permission.CHANGE_WIFI_MULTICAST_STATE)
'Added 8/19/20 to open pdfs
AddManifestText(<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
)
AddApplicationText(
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="$PACKAGE$.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)
As always thanks for your help.
Last edited: