Sending message through WhatsApp

前端 未结 23 2522
萌比男神i
萌比男神i 2020-11-22 09:42

Since I found some older posts, that tell that whatsapp doesn\'t support this, I was wondering if something had changed and if there is a way to open a whatsapp \'chat\' wit

23条回答
  •  深忆病人
    2020-11-22 10:10

    From the documentation

    To create your own link with a pre-filled message that will automatically appear in the text field of a chat, use https://wa.me/whatsappphonenumber/?text=urlencodedtext where whatsappphonenumber is a full phone number in international format and URL-encodedtext is the URL-encoded pre-filled message.

    Example:https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale

    Code example

    val phoneNumber = "13492838472"
        val text = "Hey, you know... I love StackOverflow :)"
        val uri = Uri.parse("https://wa.me/$phoneNumber/?text=$text")
        val sendIntent = Intent(Intent.ACTION_VIEW, uri)
        startActivity(sendIntent)
    

提交回复
热议问题