简体   繁体   English

如何提供ArrayList <Uri> Intent的内容。ACTION_GET_CONTENT

[英]How to provide ArrayList<Uri> content for Intent.ACTION_GET_CONTENT

I have an app where you can select multiple images. 我有一个应用程序,您可以在其中选择多个图像。 This app also will appear in the chooser dialog for attachments of images from different clients like Gmail, Message app, WhatsApp etc. When i open WhatsApp and i press attach photo, i will choose my app, select multiple images and i will set them to be returned to WhatsApp. 该应用程序还将出现在选择器对话框中,以显示来自不同客户端(如Gmail,邮件应用程序,WhatsApp等)的图像附件。当我打开WhatsApp并按附加照片时,我将选择我的应用程序,选择多张图像并将其设置为返回到WhatsApp。 How to send multiple images to client? 如何发送多个图像到客户端? Here is what i wrote: 这是我写的:

 ArrayList<Uri> uris = new ArrayList<Uri>();
 for (int i = 0; i < tempFile.size(); i++)
  { File fileIn = tempFile.get(i);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
  }
  if (tempFile != null) {
  Intent data = new Intent(Intent.ACTION_SEND_MULTIPLE);    
  data.setType("image/png");
  data.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
  MainActivity.getInstance().setResult(Activity.RESULT_OK,data);
  getActivity().finish();

Thanks for help! 感谢帮助!

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));

sure this will help you.The official docoment teaches how to send multiple images to another application..you can use this code to share multiple images to to target application> 确保这将对您有帮助。官方文档教了如何将多个图像发送到另一个应用程序。您可以使用此代码将多个图像共享到目标应用程序>

http://developer.android.com/training/sharing/send.html#send-multiple-content http://developer.android.com/training/sharing/send.html#send-multiple-content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM