cancel
Showing results for 
Search instead for 
Did you mean: 

how to open whatsapp or whatsapp business with intent android studio?

HolfordBroadnax
Member

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();
    }
2 REPLIES 2

SamBil15
Member
  1. STEP 1 : Create new Android Studio Project.
  2. STEP 2 : After Creating new Project go to res->layout->activity_main.xml.
  3. STEP 6: And this is the final step now open your MainActivity.java file and add below code.
  4. STEP 7 : OUTPUT.

SamBil15
Member

@SamBil15 wrote:
  1. STEP 1 : Create new Android Studio Project.
  2. STEP 2 : After Creating new Project go to res->layout->activity_main.xml.
  3. STEP 6: And this is the final step now open your MainActivity.java file and add below code.
  4. STEP 7 : OUTPUT.  myLoneStar login

Is this helpful or not?