如何在Facebook上分享图像和文字?

时间:2013-12-03 06:28:16

标签: android facebook share

我可以在Facebook Messenger中分享图片和文字,但不能在Facebook上分享。怎么做?我使用以下代码。

  Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); 
    sharingIntent.setType("image/jpg");         
    sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); 
    sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status"); 
    context.startActivity(Intent.createChooser(sharingIntent, "Share using"));

2 个答案:

答案 0 :(得分:1)

Facebook目前不支持:

    除了网址
  • EXTRA_TEXT
  • 来自外部来源的
  • EXTRA_STREAM(仅限本地文件)

在Facebook支持这些功能之前,您仅限于没有任何文字的本地图像。

答案 1 :(得分:0)

试试如下:

String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + 
                "/OnItsOwn/";

File dir = new File(file_path);
dir.mkdirs();
File file = new File(dir, "sample.jpg");
FileOutputStream fOut = new FileOutputStream(file);
screenshot.compress(Bitmap.CompressFormat.PNG, 100, fOut);

fOut.flush();
fOut.close();

// Share
Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
share.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
startActivity(Intent.createChooser(share, "Share Image"));
相关问题