hi am an android developer my requirement is to send a whatsapp message to particular mobile number pro-grammatically without user involvement (that is like google voice where we can send message to particular contact by voice command), i have tried many ways but only able to open whatsapp app and put the message which i want send, but facing problem in sending pro-grammatically to that contact kindly give suggestions this is what i tried How can I open WhatsApp's conversation activity using contact data? thanks in advance
Asked
Active
Viewed 9,621 times
2
-
Check out my answer at http://stackoverflow.com/a/40285262/5879376 – Rishabh Maurya Apr 05 '17 at 12:09
-
@RishabhMaurya, it will open whats app conversation screen only, you can even set message to it. You have to type it manually :) – Geek Apr 05 '17 at 12:17
-
It is the best option so far. You can't expect option like Google assistant . – Rishabh Maurya Apr 05 '17 at 12:19
2 Answers
1
Try this :
Intent myIntent = new Intent("android.intent.action.MAIN");
myIntent.setComponent(new ComponentName("com.whatsapp","com.whatsapp.Conversation"));
myIntent.putExtra("abc", PhoneNumberUtils.stripSeparators("PHONE_NUMBER")+"@s.whatsapp.net");
startActivity(myIntent);
Where PHONE_NUMBER is number of the contact to which you want to send the message.

Maciej Kamieniak
- 76
- 5
0
Uri uri = Uri.parse("smsto" + "12345");
Intent i= new Intent(Intent.ACTION_SENDTO,uri);
i.setPackage("com.whatsapp");
startActivity(i);