Intent 为 whats 应用程序添加额外内容不起作用

Intent put extra for whats app doesn't work

我在 whatsapp 应用程序中创建了一个意图,如果我单击 phone 号码的列表,它将打开 whatsapp 并打开对话(如果该号码存在于 whatsapp 中)。我成功了,直到打开对话。让我陷入困境的是,我在 intent put extra 中的信息不起作用。所以它不会在 whatsapp 文本框中显示任何内容。

这是我的意图代码:

rvListWa!!.addOnItemTouchListener(RecyclerItemClickListener(this@ShareFileActivity,
            RecyclerItemClickListener.OnItemClickListener { view, position ->

        val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
        val intent = Intent(Intent.ACTION_VIEW)
        intent.data = Uri.parse(url)
        intent.putExtra(Intent.EXTRA_TEXT, "This is an example of the text that will be sended")
        startActivity(intent)

    }))

它已经成功进入了whatsapp的公开对话,但没有加上额外的。

这个问题有什么解决办法吗?尽快。

这可以在没有 Intent.EXTRA_TEXT

的情况下完成

试试这个

val msg = "This is going to be the message"
val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa + "&text="+msg
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
startActivity(intent)

添加intent.setType("text/plain")