【问题标题】:Intent put extra for whats app doesn't workIntent put extra for whats app 不起作用
【发布时间】:2018-11-16 08:40:57
【问题描述】:

我在 whatsapp 应用程序中创建了一个意图,如果我单击电话号码列表,它将打开 whatsapp 并打开对话(如果该号码存在于 whatsapp 中)。我成功了,直到打开对话。让我陷入困境的事情是,我的意图中的信息 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 中的公开对话,但不是通过 put extra。

这个问题的任何解决方案?尽快。

【问题讨论】:

  • 尝试根据您的意图设置intent.setType("text/plain");
  • 它不起作用@KaranMer

标签: android android-intent kotlin whatsapp


【解决方案1】:

这可以在没有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")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    • 2012-12-02
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多