简体   繁体   English

如何在不使用手机号码的情况下从扫描的 QRCode 从 andorid 应用程序打开 whatsapp 聊天?

[英]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.

相关问题 如何使用意图从我的应用程序打开 whatsapp 主屏幕 - how to open whatsapp home screen from my app using intents 如何通过特定联系人从其他应用程序打开Whatsapp? - How to open Whatsapp from other app with a specific contact? 成功地以编程方式打开了指定号码的WhatsApp聊天框。 如何以编程方式向同一聊天发送消息? - Successfully managed to open up WhatsApp chatbox of specified number programatically. How to send a message to the same chat programatically? 导入从Motorola移动设备扫描的条形码 - Import barcode scanned from motorola mobile device 如何打开使用QRcode在GWT上创建的表单? - How to open a form created on GWT using QRcode? 从我的 android 应用程序打开特定的 whatsapp 联系人 - open specific whatsapp contact from my android app WhatsApp for Web如何从应用程序获取数据 - How WhatsApp for Web gets data from app 如何在API 24及更高版本中的另一个应用程序中打开文件-Andorid - How to open a file in another app in API 24 and above - andorid 如何在Andorid 6.0中直接拨出号码而没有选择器弹出窗口 - How to dial a number out without chooser popup in directly in andorid 6.0 如何使用Java从扫描的文档集中检测空白图像? - How to detect blank images from set of scanned documents using java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM