如何在Android中使用添加轻松共享动作来共享捕获的照片?

时间:2013-11-20 07:36:41

标签: android

我正在我的应用程序中进行照片共享。因为我正在使用添加一个简单的共享Action.it在操作栏中只显示图标,而不是选项。所以请给我一些例子。

http://developer.android.com/training/sharing/shareaction.html

1 个答案:

答案 0 :(得分:2)

Easy Share是自动填充;您只需告诉 ShareActionProvider 您将分享的内容。

大部分内容都是在您提供的API链接中共享的,但如果您的目标是为要共享的图片填充列表,则需要包含此链接。

  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  shareIntent.setType("image/*");
  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());

现在 shareIntent 已设置为图片,它将使用相关应用填充列表,例如instagram,Facebook或PhotoShop。

当您调用 shareIntent.setType 时,应用会在此处找到的其中一种类型中将图像视为 MIME 类型(Multipurpose Internet Mail Extension)。