How to Open Whatsapp Using an Intent in Your Android App

How to open both WhatsApp and GB-Whatsapp using an Intent in your Android App

To handle business whatsapp, GB-Whatsapp and normal whatsapp, the url scheme intent needs to be used, since the normal method of using package "com.whatsapp" only works for normal whatsapp.

Here's the code sample to handle gb, normal and business whatsapp :

try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("whatsapp://send?phone="+ "+92300xxxxxxx" +"&text=" + URLEncoder.encode("Message\n", "UTF-8")));
} catch (Exception e){
Toast.makeText(context, "Whatsapp not installed!", Toast.LENGTH_LONG).show();

Sending message through WhatsApp

Please refer to

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.


Don't use:


Original answer
Here is the solution

public void onClickWhatsApp(View view) {

PackageManager pm=getPackageManager();
try {

Intent waIntent = new Intent(Intent.ACTION_SEND);
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.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));

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


Also see

How to open Whatsapp from other app

Did you try this

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.whatsapp");

Related Topics

Leave a reply