Android fileprovider外部文件路径共享为空
我看到了很多代码和示例,但我的应用程序还不能正常工作, 我想在网上分享我的照片Android fileprovider外部文件路径共享为空,android,android-fileprovider,Android,Android Fileprovider,我看到了很多代码和示例,但我的应用程序还不能正常工作, 我想在网上分享我的照片 /storage/emulated/0/Android/data/ir.esfandane.mohsen/files/Download/类似的文件夹 /storage/emulated/0/Android/data/ir.esfandane.mohsen/files/Download/cnt_imags/images/n1/n1(18).jpg,我在清单中定义了一个提供者: <provider
/storage/emulated/0/Android/data/ir.esfandane.mohsen/files/Download/
类似的文件夹
/storage/emulated/0/Android/data/ir.esfandane.mohsen/files/Download/cnt_imags/images/n1/n1(18).jpg
,我在清单中定义了一个提供者:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
但是当发送到其他应用程序时,不要共享任何东西。你创建了一个
Uri
,然后你什么也没做。对于ACTION\u SEND
,您将Uri
附加为EXTRA\u流
EXTRA
更多信息,请参阅
File file = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
File f = new File(file.getPath() + File.separator + "cnt_imags" + File.separator);
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = FileProvider.getUriForFile(ReadActivity.this, BuildConfig.APPLICATION_ID ,fA); .....
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/png");
startActivity(intent);