Android Intent to call Whatsapp from code

前端 未结 3 1298
暖寄归人
暖寄归人 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 14:58

    WhatsApp for an specific phone number

    val whatsAppIntent = Intent(Intent.ACTION_VIEW)
    val encodedText = URLEncoder.encode("Helo World", "UTF-8")
    whatsAppIntent.data = Uri.parse("http://api.whatsapp.com/send?phone=$phoneNumber&text=$encodedText")
    

提交回复
热议问题