请帮忙,我是android编程的新手,对不起我的英语。我正在将android共享文件“PDF”共享到其他应用程序中,该过程是从Android共享文件开始的,但仍然无法正常工作,总是显示错误
java.lang.IllegalArgumentException:未能找到包含 /temp.PDF 的已配置根
单击文件时会发生上述错误。
下载ListPDF.java
try {
fileUri = FileProvider.getUriForFile(DownloadListPDF.this,
"id.dutapulsa.bayartagihan.extension.FileProvider",
requestFile); //<-- in this line that shows errors
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
清单.xml
<activity
android:name="DownloadListPDF"
android:label="List Struk"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="application/pdf" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="id.dutapulsa.bayartagihan.extension.FileProvider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
文件路径.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path path="pdf/" name="pdf" />
</paths>
并来自 logcat
06-25 09:47:18.282: W/System.err(20144): java.lang.IllegalArgumentException: Failed to find configured root that contains /temp.PDF
06-25 09:47:18.283: W/System.err(20144): at id.dutapulsa.bayartagihan.extension.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:327)
06-25 09:47:18.283: W/System.err(20144): at id.dutapulsa.bayartagihan.extension.FileProvider.getUriForFile(FileProvider.java:89)
06-25 09:47:18.283: W/System.err(20144): at id.dutapulsa.bayartagihan.DownloadListPDF$1.onItemClick(DownloadListPDF.java:56)
06-25 09:47:18.284: W/System.err(20144): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
06-25 09:47:18.284: W/System.err(20144): at android.widget.AbsListView.performItemClick(AbsListView.java:1300)
06-25 09:47:18.284: W/System.err(20144): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3034)
06-25 09:47:18.284: W/System.err(20144): at android.widget.AbsListView$1.run(AbsListView.java:3834)
06-25 09:47:18.284: W/System.err(20144): at android.os.Handler.handleCallback(Handler.java:800)
06-25 09:47:18.284: W/System.err(20144): at android.os.Handler.dispatchMessage(Handler.java:100)
06-25 09:47:18.284: W/System.err(20144): at android.os.Looper.loop(Looper.java:194)
06-25 09:47:18.284: W/System.err(20144): at android.app.ActivityThread.main(ActivityThread.java:5469)
06-25 09:47:18.284: W/System.err(20144): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 09:47:18.284: W/System.err(20144): at java.lang.reflect.Method.invoke(Method.java:525)
06-25 09:47:18.284: W/System.err(20144): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:857)
06-25 09:47:18.284: W/System.err(20144): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
06-25 09:47:18.284: W/System.err(20144): at dalvik.system.NativeStart.main(Native Method)