【问题标题】:fileprovider external-files-path share empty文件提供者外部文件路径共享为空
【发布时间】: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


    【解决方案1】:

    你创建了一个Uri,然后你什么也没做。对于ACTION_SEND,您附加Uri 作为EXTRA_STREAM 额外。

    请参阅the documentation 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多