Sending message through WhatsApp

how to send whatsapp message to someone not in contacts
whatsapp://send?text=message
how to send whatsapp message to new number
how to send whatsapp message to multiple contacts
send whatsapp message from website
send anonymous whatsapp message online
android studio send whatsapp message automatically
send whatsapp messages to someone not on your contact list?

Since I found some older posts, that tell that whatsapp doesn't support this, I was wondering if something had changed and if there is a way to open a whatsapp 'chat' with a number that I'm sending through an intent?

UPDATE Please refer to https://faq.whatsapp.com/en/android/26000030/?category=5245251

WhatsApp's Click to Chat feature allows you to begin a chat with someone without having their phone number saved in your phone's address book. As long as you know this person’s phone number, you can create a link that will allow you to start a chat with them.

Use: https://api.whatsapp.com/send?phone=15551234567

Don't use: https://api.whatsapp.com/send?phone=+001-(555)1234567

Example: https://api.whatsapp.com/send?phone=15551234567&text=I'm%20interested%20in%20your%20car%20for%20sale

Original answer Here is the solution

public void onClickWhatsApp(View view) {

    PackageManager pm=getPackageManager();
    try {

        Intent waIntent = new Intent(Intent.ACTION_SEND);
        waIntent.setType("text/plain");
        String text = "YOUR TEXT HERE";

        PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
        //Check if package exists or not. If not then code 
        //in catch block will be called
        waIntent.setPackage("com.whatsapp");

        waIntent.putExtra(Intent.EXTRA_TEXT, text);
        startActivity(Intent.createChooser(waIntent, "Share with"));

   } catch (NameNotFoundException e) {
        Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
                .show();
   }  

}

Also see http://www.whatsapp.com/faq/en/android/28000012

How to send WhatsApp message to a person not on your phone , , without saving their contact information or using any shady third party application. Well, actually there is no official way to send a message without having to press the send button. I personally have no experience for this part. But as someone in other comments suggested using appium or something that can really find the send button and automatically push the message.

With this code you can open the whatsapp chat with the given number.

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, ""));
}

What Is WhatsApp All About?, How to send WhatsApp messages from the Chats screen. Launch WhatsApp from your Home screen or the app drawer. It's the icon that looks like  You can use simple voice commands to send messages and even make calls via WhatsApp. You can start by saying “Hey Siri, send a WhatsApp message to <contact name>. Then Siri will ask what you want

I found the following solution, first you'll need the whatsapp id:

Matching with reports from some other threads here and in other forums the login name I found was some sort of: international area code without the 0's or + in the beginning + phone number without the first 0 + @s.whatsapp.net

For example if you live in the Netherlands and having the phone number 0612325032 it would be 31612325023@s.whatsapp.net -> +31 for the Netherlands without the 0's or + and the phone number without the 0.

public void sendWhatsAppMessageTo(String whatsappid) {

Cursor c = getSherlockActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
        new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
        new String[] { whatsappid }, null);
c.moveToFirst();

Intent whatsapp = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
c.close();

 if (whatsapp != null) {

startActivity(whatsapp);      

} else {
        Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
                .show();
//download for example after dialog
                Uri uri = Uri.parse("market://details?id=com.whatsapp");
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    }

}

How to send messages with WhatsApp for Android, How to send a new message in WhatsApp for iPhone. Launch WhatsApp. Tap the Chats tab on the bottom of your screen. Tap the New Chat  The first method through which you can send an anonymous message on WhatsApp is Wassame. It is a web portal which helps you to send messages on WhatsApp. Using Wassame, you cannot send just messages but you will be able to send images, audio, videos, share your location, contacts and other things too.

This should work whether Whatsapp is installed or not.

boolean isWhatsappInstalled = whatsappInstalledOrNot("com.whatsapp");
        if (isWhatsappInstalled) {
            Uri uri = Uri.parse("smsto:" + "98*********7")
            Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
            sendIntent.putExtra(Intent.EXTRA_TEXT, "Hai Good Morning");
            sendIntent.setType("text/plain");
            sendIntent.setPackage("com.whatsapp");
            startActivity(sendIntent);
        } else {
            Toast.makeText(this, "WhatsApp not Installed",
                    Toast.LENGTH_SHORT).show();
            Uri uri = Uri.parse("market://details?id=com.whatsapp");
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(goToMarket);

        }

private boolean whatsappInstalledOrNot(String uri) {
    PackageManager pm = getPackageManager();
    boolean app_installed = false;
    try {
        pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
        app_installed = true;
    } catch (PackageManager.NameNotFoundException e) {
        app_installed = false;
    }
    return app_installed;
}

How to send messages with WhatsApp for iOS, UPDATE Please refer to https://faq.whatsapp.com/en/android/26000030/?​category=5245251. WhatsApp's Click to Chat feature allows you to begin a chat with  You can only send 1 WhatsApp message per day (24 hours) for each different person. Send lots of WhatsApp messages for free, limited to 1 message per person each day (24 hours). If you have received threatening messages through our service, or is a user constantly sending your unwanted messages and you would like this to stop , then please add yourself to the block list and we will stop anybody that tries to sent to you!

Tested on Marshmallow S5 and it works!

    Uri uri = Uri.parse("smsto:" + "phone number with country code");
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
    sendIntent.setPackage("com.whatsapp");
    startActivity(sendIntent); 

This will open a direct chat with a person, if whatsapp not installed this will throw exception, if phone number not known to whatsapp they will offer to send invite via sms or simple sms message

Sending message through WhatsApp, Enable sales and support teams to answer product or customer service questions using you customers' preferred messaging app. User Verification and 2FA. Type the message you want. Now hit the “Send Text” button on the app. It will take you to the WhatsApp app. If you wish, you can edit your message there. Now hit the “Send” icon to send the message. That’s it. Your WhatsApp message is sent successfully without saving the contact to your device.

Twilio API for WhatsApp, WhatsApp comes with a 'Click to Chat' feature that allows users to begin a chat with someone without having their phone number saved in your  Problems sending or receiving messages - The most common reason why you can't send or receive WhatsApp messages is a bad Internet connection. Learn how to troubleshoot connection issues on: Android | iPhone If you're sure your phone is connected to the Internet, there are a few reasons why WhatsApp messages aren't going through: Your phone needs to be restarted or turned off and on. The

How to send WhatsApp messages to people not in your contact list , If you're sure your phone is connected to the Internet, there are a few reasons why WhatsApp Duration: 0:41 Posted: May 3, 2017 Enjoy whatsapp also on your PC. Learn how to do it completely free.

Problems sending or receiving messages, You can select multiple messages. Tap Forward . Choose the chat you wish to forward the Duration: 0:46 Posted: Aug 2, 2013

Comments
  • did you tried share action provider?
  • Sounds interesting, but how would that work. Can I share a string (phonenumber) and will it open whatsapp(or the chooser?) can you give a little example?
  • although there is ACTION_SENDTO intent in whatsapp, it is not executed (properly) hence it is not possible to do to a specific phone number [thats what i found]
  • Possible duplicate of Send text to specific contact (whatsapp)
  • i'm still looking forward attaching both image & text at the same time, but found no luck, sigh :(
  • How to integrate with messaging? so that the user can choose whatsapp or messaging
  • if we already have the contact information is it possible to add the contact information and send message without having to touch on the contact to select and click ok to send ??
  • refer to stackoverflow.com/questions/19081654/…
  • @MananMerevikSharma source doesn't lie (android.googlesource.com/platform/frameworks/base/+/refs/heads/…). Additionally, basic Java principle: an object lives until there are no longer any references to them.
  • @MananMerevikSharma -1. It does not "turn to a null pointer". The else-part can never be reached. When WhatsApp is not installed, the Intent is still sent, but a Dialog opens saying that there's no matching app. This means you are not providing any way to check whether WhatsApp is installed or not.
  • @user2957782 i followed this sir , but when i click on my button to start my whatsapp it says "No apps can perform this action "