【问题标题】:Share intent for image from sd card not showing option to share on Facebook, Google+ or any social networking site从 sd 卡共享图像的意图未显示在 Facebook、Google+ 或任何社交网站上共享的选项
【发布时间】:2013-11-25 07:11:01
【问题描述】:

我使用了一个简单的共享意图来共享存储在 sd 卡上的图像。它目前向我显示了在我的电子邮件和谷歌驱动器上共享的选项。但无法在 facebook、twitter 或任何其他社交网站上分享。

以下是我用于分享意图的代码:

        // Populate the share intent with data
        Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory()
          + File.separator + folderName + File.separator +mImageTitles.get(position)));

        // Setting up the share intent
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.setType("img/*");
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        shareIntent.putExtra(Intent.EXTRA_TEXT, mImageTitles.get(position));
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

【问题讨论】:

    标签: android facebook android-intent share


    【解决方案1】:

    换行

    shareIntent.setType("img/*");
    

    shareIntent.setType("image/*");
    

    它应该可以工作。

    【讨论】:

      【解决方案2】:

      将 facebook 帐户添加到 android 设备并检查。

      【讨论】:

        【解决方案3】:

        出于某种原因,在图像保存期间向 Mediastore 又名图库添加一个条目,有助于让所有社交网络的共享功能正常工作。

        如果有人能告诉我这种行为的原因,那就太好了..

        【讨论】:

          【解决方案4】:

          是类型吗?试试shareIntent.setType("image/*");

          或使用 MediaStore

          String path = MediaStore.Images.Media.insertImage(
                  context.getContentResolver(), bitmap, "title",
                  "description");
          
          // will be null if we don't have permissions to write external
          if (path != null) {
              Uri uri = Uri.parse(path);
              shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2012-06-07
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-06-04
            相关资源
            最近更新 更多