-1

Is it possible to send someone whatsapp Message with significant number from an android app. For example you'll write a phone number and a message into a textView. Then you'll touch the send button. Whatsapp will send message for you.

Sorry for bad English.

Thanks for your help.

oznakn
  • 90
  • 3
  • 9

1 Answers1

0

The way to do it is like this:

public void sendWhatsAppMessage() {

    PackageManager pm = getPackageManager();

    try {

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

        PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
        i.setPackage("com.whatsapp");

        i.putExtra(Intent.EXTRA_TEXT, text);
        startActivity(Intent.createChooser(i, "Share using"));

    } catch (NameNotFoundException e) {
        Toast.makeText(this, "WhatsApp is not installed on device.", Toast.LENGTH_SHORT)
            .show();
    }  

}
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • But i can't specify phone number in my app with this way. – oznakn Feb 16 '15 at 17:51
  • Possible duplicate of http://stackoverflow.com/questions/15462874/sending-message-through-whatsapp/15931345#15931345 – Apurva Feb 16 '15 at 17:53
  • As of now that cant be done. `WhatsApp` doesn't have a public API. I haven't seen any other apps that are able to send a message to a specific contact on `WhatsApp`. – Yash Sampat Feb 16 '15 at 17:53