请帮忙,我是android编程的新手,对不起我的英语。 我正在研究android共享文件" PDF"进入其他应用程序后,该过程从Android Sharing File开始,但仍然无效,始终显示错误
单击文件时出现java.lang.IllegalArgumentException:无法找到包含/temp.PDF的已配置根
错误。
DownloadListPDF.java
try {
fileUri = FileProvider.getUriForFile(DownloadListPDF.this,
"id.dutapulsa.bayartagihan.extension.FileProvider",
requestFile); //<-- in this line that shows errors
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
的Manifest.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>
filepaths.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)