1

I would like to share text and URL via WhatsApp.

I have looked into few links, but it has only share text feature.

How can i share URL + Text ?

Here is what i have tried so far.

Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
try {
    activity.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
    ToastHelper.MakeShortText("Whatsapp have not been installed.");
}
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Logger
  • 1,274
  • 1
  • 14
  • 25

2 Answers2

1
Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_TEXT, "this my text https://www.google.co.in/webhp?ei=6cLkV8utKMnp0ASg5L7oAw&yv=2&rct=j");
                sendIntent.setType("text/plain");
                sendIntent.setPackage("com.whatsapp");
                startActivity(sendIntent);
Yasin Patel
  • 5,624
  • 8
  • 31
  • 53
0

I know this is very old but concatenating the url (as text) to the text simply works for me

akiva
  • 2,677
  • 3
  • 31
  • 40