gpt4 book ai didi

android - 通过 Android Intent 将链接发送到 Whatsapp

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:44:53 26 4
gpt4 key购买 nike

我正在尝试从我的 Android 应用程序发送带有链接的短信到聊天应用程序,如 Whatsapp 或 SMS 消息。

这些应用不接受 text/html 类型作为 Intent 类型,当我使用 text/plain 类型时,我发送的消息仅包含主题,没有消息正文。

我见过可以通过 Whatsapp 共享链接的应用,例如 Chrome 和 Dolphin 浏览器应用。

这是我的代码:

    @JavascriptInterface
public void sendMessage(String trip) {
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Trip from Voyajo");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("I've found a trip in Voyajo website that might be interested you, http://www.voyajo.com/viewTrip.aspx?trip=" + trip));
startActivity(Intent.createChooser(emailIntent, "Send to friend"));
}

最佳答案

@JavascriptInterface
public void sendMessage(String trip) {
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Trip from Voyajo");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("I've found a trip in Voyajo website that might be interested you, http://www.voyajo.com/viewTrip.aspx?trip=" + trip));
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send to friend"));
}

这里我只是改变了 emailIntent.setType("text/plain"); 这条线的位置,它起作用了。你在消息传递应用程序正文中获得链接电子邮件应用程序正文。但是在这里你只能在邮件应用程序中获得主题文本而不是在消息传递应用程序中,但你可以在正文中获得你的链接以实现你的目标......

就是这样......

关于android - 通过 Android Intent 将链接发送到 Whatsapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25243143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com