【问题标题】:Facebook Doesn't appear on share windows when trying to share an Image尝试共享图像时,Facebook 不会出现在共享窗口中
【发布时间】:2013-08-03 09:56:59
【问题描述】:

我在我的应用程序中创建了一个位图,并希望使用 Intent.ACTION_SEND 通过电子邮件应用程序或 Facebook 共享它。 共享窗口打开,出现 gmail 和 yahoomail 应用程序图标,但没有 facebook 或 g+!我真的不知道有什么问题。还有一个问题是 gmail 应用程序无法附加文件(从位图创建)。我读了一些类似的问题,但我仍然有货。请帮帮我。

这是我的分享代码:

private  static File writePhotoPng(Bitmap data, String pathName) {
    File file = new File(pathName);
    try {

        file.createNewFile();
        // BufferedOutputStream os = new BufferedOutputStream(
        // new FileOutputStream(file));
        FileOutputStream os = new FileOutputStream(file);
        data.compress(Bitmap.CompressFormat.PNG, 100, os);
        os.flush();
        os.close();


    } catch (Exception e) {
        e.printStackTrace();
    }
    return file;
}

public static void ShareOnFb(Bitmap share, Activity activity, String emailSubject){
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    // EDIT:
    // !!! childish mistake. below line is correct !!! intent.setType("Image/*");
    intent.setType("image/*");
    //add data to intent, the receiving app will decide what to do with it.

    // email subject:
    if (emailSubject != null && !emailSubject.equals("")){
        intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
    }



    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(writePhotoPng(share, "temp.png")));

    activity.startActivity(Intent.createChooser(intent, "Share on"));
}

【问题讨论】:

    标签: android facebook android-intent bitmap share


    【解决方案1】:

    在纠正了我幼稚的错误(参见有问题的编辑部分)并使用this 代码 sn-p 后,我终于解决了这个问题。

    如果有人知道使用 contentValue 和我的方法有什么区别,请与我分享。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-04
    • 1970-01-01
    相关资源
    最近更新 更多