How Do I Open Conversation Of A Particular Contact In Whatsapp
I want to send a message using whatsapp only to a particular contact without the user having to select it from his contact list. I am using the below code to fire an intent Intent
Solution 1:
Try the below code.
try {
String num= "+918888888888"; // contains spaces.
num= num.replace("+", "").replace(" ", "");
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.putExtra("jid", num+ "@s.whatsapp.net");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Test");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.setType("text/plain");
startActivity(sendIntent);
} catch (Exception e) {
app.showSnackBar(parentView, "Whatsapp have not been installed.");
}
Post a Comment for "How Do I Open Conversation Of A Particular Contact In Whatsapp"