TrinityTuts Tips

Send Message to Specific number on WhatsApp Android

In this post I am going to share a code for Android through which we can send message to specific number using Android Code Programmatically from our Application.

Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "Your Message Here");

String smsNumber = "910000000000"; //Number without with country code and without '+' prifix
whatsappIntent.putExtra("jid", smsNumber + "@s.whatsapp.net");

if (whatsappIntent.resolveActivity(getPackageManager()) == null) {
    Toast.makeText(Home.this, "Whatsapp not installed.", Toast.LENGTH_SHORT).show();
    return;
}

startActivity(whatsappIntent);

Hope this code help you.