我正在尝试使用 ACTION_SEND_MULTIPLE Intent 同时共享视频文件和文本。
现在,这在 GMAIL 中有效(附件中的视频和邮件正文中的文本),但是我也想在 Whatsapp 中做同样的事情,但它没有出现在 Intent 的应用程序列表中。
我的代码是下一个:
Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Descarga la app en...");
ArrayList<Uri> contenidos = new ArrayList<Uri>();
File file = new File(Environment
.getExternalStorageDirectory()
.getAbsolutePath()
+ "/Talking/"
+ nombreVideo
+ ".3gp");
Uri screenshotUri = Uri.fromFile(file);
contenidos.add(screenshotUri);
//sharingIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri);
sharingIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, contenidos);
sharingIntent.setType("video/3gpp");
startActivity(Intent.createChooser(sharingIntent, "Share video using"));
感谢您的帮助。
最佳答案
由于 whatsapp 的新更新,现在您的代码可以工作了,在此之前它不接受这种 Intent (ACTION_SEND_MULTIPLE),因为它一次只接受一个文件。
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
shareIntent.setType("image/png");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM,
Uri.parse("file:///mnt/sdcard/UserImages/"+ ParseUser.getCurrentUser().getObjectId() + ".png"));
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Hello test");
startActivity(Intent.createChooser(shareIntent,"Share"));
关于带有视频和文字的 Android ACTION_SEND_MULTIPLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11798660/