提供商ERR_UNKNOWN_URL_SCHEME當負載文本文件中的manifest.xml使用fileprovider
<!-- File Provider -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.test.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
資源文件
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
使用fileprovider
Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".fileprovider", file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "*/*");
intent.startActivity(intent);
的10
參考:here
說明: 我無法打開圖像,文本文件,使用此文件提供PDF格式。 當我打開文件文本文件,它給我ERR_UNKNOWN_URL_SCHEME。 如果我打開圖片或PDF它沒有顯示任何
請告訴uri.toString()的值。 – greenapps
和file.getAbsolutePath()。 – greenapps
/存儲/模擬/ 0/KOOPSv3Sales/KOOPSv3Sales郵件附件/ 29ca8aed.txt –