intent code:
'Asking and getting rp.PERMISSION_WRITE_EXTERNAL_STORAGE is done, also confirmed in Settings/permission of device and checked through a process variable before executing the below code
Dim properFileStr As String = "file://" & StrPath.trim
Dim i As Intent 'Requires a reference to the Phone library
i.Initialize(i.ACTION_VIEW, properFileStr)
Dim Pos As Int = properFileStr.LastIndexOf(".")
Dim Ext As String = properFileStr.SubString(Pos)
'Type must be set after calling SetFileUriAsIntentData
Starter.Provider.SetFileUriAsIntentData(i, properFileStr )
Select Case Ext.ToUpperCase
Case "JPG"
i.SetType("image/*")
Case "TXT"
i.SetType("text/plain")
Case "PNG"
i.SetType("image/*")
End Select
Try
StartActivity(i)
Catch
ToastMessageShow("couldn't open the file in default viewer", False) 'not executed in my case
ToastMessageShow(properFileStr, True)
End Try
I started by copying FileProvider example's fileprovider, starter, manifest code as is. When supplied path is "/storage/emulated/0/Download/myText.txt" choosing chrome as the target app reveals the final pointed path to be "content://my.packagename.provider/name/file%3A/storage/emulated/0/Download/myText.txt" which is shown by various apps (including chrome) that open through the chooser dialog as Requested file was not found. Keeping or removing file:// prepender code only keeps or removes that part of the final path - "file%3A" but, the behavior is same.
Code:
'. . .android:targetSdkVersion="26"
. . . .
'==================================File Provider ** Starts
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" />
)
Since nothing is found in the release mode logs, I need some expert advice here about how to tackle the problem. Am I missing something in the Manifest/Permission or is it the intent? Using FileProvider since the ordinary file:// based opening through intent throws the uri exposed error (sdk 26).
Last edited: