I saw this answer How to open WhatsApp using an Intent in your Android App. But nowadays, people prefer using GBWhatsapp instead of the main Whatsapp. I want my app to still be able to send message to either of any of the two, if any are installed. How would I check if GBWhatsapp is installed and then open it up, then send a message to a particular number?
Asked
Active
Viewed 676 times
0
-
1That works the same for any app. just replace the package name of WhatsApp with GB WhatsApp package name. And that takes the user to the GB WhatsApp `com.gbwhatsapp` – Venkatesh Talacheeru Jun 12 '21 at 15:04
1 Answers
1
This is the code you can use to take users to the GB WhatsApp application. Always use the try and catch method to catch the issue if the app is not installed in the user device.
try{
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.gbwhatsapp");
startActivity(Intent.createChooser(sendIntent, ""));
startActivity(sendIntent);
}catch(Exception e){
e.printStackTrace();
}

Venkatesh Talacheeru
- 168
- 1
- 10