Android Question Version/API Question

MrKim

Well-Known Member
Licensed User
Forgive me for being a little slow to grasp some of this stuff.
I am trying to figure out how to share a file with other apps: Android Question Need help with File Provider/FilePicker.

One of the things that has confused me is I keep reading that the code below:
B4X:
Sub OpenPdf(FName As String)
    Dim i As Intent 'Requires a reference to the Phone library
    Try
        i.Initialize(i.ACTION_VIEW, "file:///" & FName)
        i.SetType("application/pdf")
        i.WrapAsIntentChooser("Choose PDF Viewer")
        StartActivity(i)
    Catch
        Msgbox("Error opening " & FName & CRLF & LastException.Message, "Open PDF Error")
    End Try

End Sub
and this:
B4X:
            If File.ExternalWritable And File.ExternalReadable Then
                SKUtils.GlblNC.LD = File.DirDefaultExternal

End If
Should not work in Android 7 yet the code above has been working fine in Android 7/7.1.1. I have also been moving files on and off a Windows server using SMB lib, and also copying those files in and out of both internal and external directories without using RunTimePermissions. File.DirDefaultExternal has been working just fine.

My target SDK for the apps that are doing this is 26.

Where it seems to be falling apart is Android 8.

What am I missing here?
 

Erel

Administrator
Staff member
Licensed User
and also copying those files in and out of both internal and external directories without using RunTimePermissions. File.DirDefaultExternal has been working just fine.
It will stop working once you uninstall the app and install it again. It kept the implicit external storage permission from a previous version.

1. You must use runtime permissions to access external folder, except of GetSafeDirDefaultExternal.
2. You must use FileProvider class if you want to share files.
 

MrKim

Well-Known Member
Licensed User
It will stop working once you uninstall the app and install it again. It kept the implicit external storage permission from a previous version.

1. You must use runtime permissions to access external folder, except of GetSafeDirDefaultExternal.
2. You must use FileProvider class if you want to share files.
Previous version of what? My app? The tablet Android version? - No, the tablet with 7.1.1 is new, the app just installed. When I get a moment I will uninstall and reinstall my app to confirm. I may not have noticed a system update - memories not so good any more:rolleyes:.
 
Top