Facebook Doesn't appear on share windows when trying to share an Image

拜拜、爱过 提交于 2019-12-20 07:35:41

问题


I create a bitmap in my app and want to share it via email apps or Facebook using Intent.ACTION_SEND. the share window opens and gmail and yahoomail apps icon appear but no facebook or g+! I really doesn't know what's the problem. There is another problem that gmail app cannot attach the file (created from bitmap). I read a few similar questions but still I'm stocked. Help me please.

here is my code for sharing:

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"));
}

回答1:


after correcting my childish mistake (see EDIT part in question) and Using this code snippet I finally solved this problem.

if anybody knows whats the difference between using contentValue and my approach please share that with me.



来源:https://stackoverflow.com/questions/18031587/facebook-doesnt-appear-on-share-windows-when-trying-to-share-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!