[英]how to open whatsapp chat from andorid app from scanned QRCode without using mobile number?
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上面的代码用给定的数字打开 whatsappchat
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"用扫描仪扫描 whtsapp QRcode 后,它会给出类似“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.您无法从二维码中获取电话号码,因为
../qr/
之后的值已被 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.如果您只想打开 WhatsApp 应用程序(稍后会要求您添加联系人),一旦您获得二维码链接
https://wa.me/qr/YOUR_CODE
,您就可以使用正常意图打开 url。 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 :下面的代码应该可以完成工作,您将看到一个对话框,提示您在浏览器或Whatsapp 之间进行选择(如果已安装) :
val url = "https://wa.me/qr/YOUR_CODE"
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
startActivity(intent)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.