Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.putExtra("jid", "91123456798" + "@s.whatsapp.net");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
above code opens whatsappchat with given number
mCodeScanner.setDecodeCallback(new DecodeCallback() {
@Override
public void onDecoded(@NonNull Result result) {
log.w("whatsappString" ,+result);
}
after scanning whtsapp QRcode with scanner it gives result like "https://wa.me/qr/VDHOMK2DXDDD1"
how to open perticular person chat using above link ? as i can not get mobile number after scanning code Thanks in advance.
You cannot get the phone number from the QR since the value after ../qr/
is decoded by WhatsApp.
If you only want to open the WhatsApp application (that will later ask you to add the contact), once you have the qr code link https://wa.me/qr/YOUR_CODE
you can just open the url using a normal intent. The code below should do the work and you will see a dialog prompting to chose between a browser or Whatsapp if it is installed:
val url = "https://wa.me/qr/YOUR_CODE"
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
startActivity(intent)