Android Intent to call Whatsapp from code

前端 未结 3 1346
暖寄归人
暖寄归人 2021-01-28 14:29

I am using this code to call WhatsApp directly from my Call Logs app. This works well, but only if the phone number includes a valid country code. For example calling WhatsApp

3条回答
  •  感动是毒
    2021-01-28 15:05

      Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setType("text/html");
            sharingIntent.setPackage("com.whatsapp");
            sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("

    https://play.google.com/store/apps/details?id=" + context.getPackageName() + "

    ")); context.startActivity(Intent.createChooser(sharingIntent, "Share using"));

提交回复
热议问题