如何通过Android中的WhatsApp共享图像+文本+ URL?

时间:2015-07-11 06:56:00

标签: android android-intent

我想通过WhatsApp分享文字,图片和网址。

我查了几个链接,但它只有共享文字功能。

Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "text here");
try {
    activity.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
    ToastHelper.MakeShortText("Whatsapp have not been installed.");
}

1 个答案:

答案 0 :(得分:0)

Uri imageUri = Uri.parse(pictureFile.getAbsolutePath());
    Intent Intent = new Intent();
   Intent.setAction(Intent.ACTION_SEND);
    Intent.setPackage("com.whatsapp");
     Intent.putExtra(Intent.EXTRA_TEXT, picture_text);
    Intent.putExtra(Intent.EXTRA_STREAM, imageUri);
   Intent.setType("image/jpeg");
   Intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        startActivity(Intent);
    } catch (android.content.ActivityNotFoundException ex) {
        ToastHelper.MakeShortText("Whatsapp not installed.");
    }