【问题标题】:how to open whatsapp chat from andorid app from scanned QRCode without using mobile number?如何在不使用手机号码的情况下从扫描的 QR 码从 android 应用程序打开 whatsapp 聊天?
【发布时间】:2021-08-20 11:37:52
【问题描述】:
 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);

上面的代码打开给定数字的whatsappchat

mCodeScanner.setDecodeCallback(new DecodeCallback() {

            @Override
            public void onDecoded(@NonNull Result result) {
              log.w("whatsappString" ,+result);
}

使用扫描仪扫描 whtsapp QRcode 后,它会给出类似“https://wa.me/qr/VDHOMK2DXDDD1”的结果

如何使用上面的链接打开特定的人聊天?因为扫码后无法获取手机号码 提前致谢。

【问题讨论】:

    标签: java android android-studio decode qr-code


    【解决方案1】:

    无法从 QR 获取电话号码,因为 ../qr/ 之后的值已被 WhatsApp 解码。
    如果您只想打开 WhatsApp 应用程序(稍后会要求您添加联系人),一旦您拥有 qr 代码链接https://wa.me/qr/YOUR_CODE,您就可以使用正常意图打开 url。下面的代码应该可以完成工作,您将看到一个对话框,提示您在浏览器或 Whatsapp(如果已安装)之间进行选择:

    val url = "https://wa.me/qr/YOUR_CODE"
    val intent = Intent(Intent.ACTION_VIEW)
    intent.data = Uri.parse(url)
    startActivity(intent)
    

    【讨论】:

      猜你喜欢
      • 2020-01-04
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 2018-07-24
      • 2018-02-13
      相关资源
      最近更新 更多