Reply
Member
Posts: 1
Registered: a month ago
0

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

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();
    }
Member
Posts: 2
Registered: 2 weeks ago
0

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

  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.
Member
Posts: 2
Registered: 2 weeks ago
0

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


@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? 

/* /