2

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

Community
  • 1
  • 1
Abhilash
  • 31
  • 1
  • 3

2 Answers2

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.

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