Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send a whatsapp message automatically

Tags:

android

how to send a whatsapp message to a specific contact automatically?I have searched but it just opens the chat of that specific person but does not send the message automatically

Here is the code that am using:

private void openWhatsappContact(String number) {
    Uri uri = Uri.parse("smsto:" + number);
    Intent i = new Intent(Intent.ACTION_SENDTO, uri);
    i.setPackage("com.whatsapp");  
    startActivity(Intent.createChooser(i, ""));
like image 983
so05 Avatar asked Jan 19 '15 05:01

so05


1 Answers

I'm not sure you can send the message automatically, but try this to specify the message you want to send:

i.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");

Reference: https://www.whatsapp.com/faq/en/android/28000012

like image 99
vinitius Avatar answered Oct 21 '22 13:10

vinitius