【发布时间】:2018-01-21 14:03:21
【问题描述】:
我看到了很多代码和示例,但我的应用程序还不能正常工作,
我想分享我的图片
/storage/emulated/0/Android/data/ir.esfandune.mohsen/files/Download/ 文件夹喜欢
/storage/emulated/0/Android/data/ir.esfandune.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>
和 XML:
我的代码是:
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);
但是当发送到其他应用时,不要分享任何东西
【问题讨论】:
标签: android android-fileprovider