jotajota52
Member
Hi!
While trying to send an e-mail using the FileProvider class, I'm getting the "Couldn't find meta-data for provider" error
in line 34 of the class:
This is what I've added to the manifest file:
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"></meta-data>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)
and my code. I first create a list of files that the user marks as attachments to include in the message. The pl.tag is the filename in the custom list view:
I have checked that the "shared" folder is created by the FileProvider class, and the selected files are passed correctly to the class GetFileUri sub.
Please help!!
While trying to send an e-mail using the FileProvider class, I'm getting the "Couldn't find meta-data for provider" error
in line 34 of the class:
B4X:
Return fp.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
This is what I've added to the manifest file:
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"></meta-data>
</provider>
)
CreateResource(xml, provider_paths,
<files-path name="name" path="shared" />
)
and my code. I first create a list of files that the user marks as attachments to include in the message. The pl.tag is the filename in the custom list view:
B4X:
Dim filename As String
checkedJobs.Initialize
Dim i As Int=0
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, result As Boolean)
If result Then
For i = 0 To clvFiles.GetSize - 1
Dim p As B4XView = clvFiles.GetPanel(i)
Dim pl As B4XView =p.GetView(1)
Dim chk As B4XView = p.GetView(0)
If chk.Checked Then
filename=pl.tag
File.Copy(JobDir,pl.Tag,Starter.Provider.SharedFolder,filename)
checkedJobs.Add(filename)
End If
Next
End If
Dim msg As Email
msg.Subject ="Job files -" & DateTime.Date(DateTime.Now)
msg.Body ="Database files from user: " & usuario & CRLF & "Date: " & DateTime.Date(DateTime.Now)
For i=0 To checkedJobs.Size-1
filename = checkedJobs.Get(i)
msg.Attachments.Add(Starter.Provider.GetFileUri(filename))
Next
Dim intMsg As Intent = msg.GetIntent
intMsg.Flags=1
StartActivity(intMsg)
I have checked that the "shared" folder is created by the FileProvider class, and the selected files are passed correctly to the class GetFileUri sub.
Please help!!