I'm using this code, and it opens WhatsApp, but it doesn't allow me to open WhatsApp business, is there any way to verify which WhatsApp the user has installed?
String contact = phone;
Double amount_total = pac_val_amo + del_fac_amo;
String total = "S/. " + String.format("%.2f", amount_total);
String message = "Su pedido de " + store + " ha llegado, su pago total es de S/. " + total;
String url = "https://api.whatsapp.com/send?phone=" + contact + "&text=" + message;
try {
PackageManager pm = getContext().getPackageManager();
pm.getPackageInfo("com.whatsapp", PackageManager.GET_ACTIVITIES);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(getContext(), "WhatsApp is not installed on this Device.", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
@SamBil15 wrote:
- STEP 1 : Create new Android Studio Project.
- STEP 2 : After Creating new Project go to res->layout->activity_main.xml.
- STEP 6: And this is the final step now open your MainActivity.java file and add below code.
- STEP 7 : OUTPUT. myLoneStar login
Is this helpful or not?