I want to open chooser for both whatsapp and gb-whatsapp so the user can choose any of one from them. This code is only opening whatsapp only.
Intent intentWhatsapp = new Intent(Intent.ACTION_VIEW);
String url = "https://chat.whatsapp.com/JPJSkaiqmDu5gLKqUPAfMM";
intentWhatsapp.setData(Uri.parse(url));
intentWhatsapp.setPackage("com.whatsapp");
startActivity(intentWhatsapp);
2
Answers
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 :
Simple answer you can’t.
More detailed answer: You can only create an Intent targeting one specific app. I would suggest building a dialogue inside your app, showing the app images of whatsapp and gb-whatsapp, and then putting specific intents behind those two images so that it "looks" like the Android chooser.