Android Question Requesting dangerous write permission with TargetSDKVersion 29

Status
Not open for further replies.

Scantech

Well-Known Member
Licensed User
Longtime User
I believe Starter.rp.Check(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE) will not work with TargetSDKVersion 29 and android-29? I do not see the permission screen.

I included the legacy manifest as required.
 
There is a temporary workaround for API 29 on this page:

 
Upvote 0
B4X: Copy
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult(perm As String,res As Boolean)
Log(test)

Just FYI. Log(test) will never run with targetsdkversion 29. I think we need to eliminate this dangerous permission. Any codes below it will never run.
 
Upvote 0
i believe you missed one thing that you should also use sdk-29 for this purpose

 
Upvote 0
I think i understand whats going on now. The SetApplicationAttribute(android:requestLegacyExternalStorage, true) will only work with the apps that accepted write permission in TargetSDKVersion 28 or lower.

If app is uninstalled and reinstalled with TargetSDKVersion 29, then the write permission won't work and File.DirRootExternal is useless.
 
Upvote 0
That's not true. It works exactly as before. Tested with this code and a new package name:
Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Dim rp As RuntimePermissions
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        File.WriteString(File.DirRootExternal, "1.txt", "ttt")
    End If
End Sub
 
Upvote 0
Status
Not open for further replies.
Back
Top