小编ela*_*zaa的帖子

通过Android Intent发送链接到Whatsapp

我正在尝试发送带有从我的Android应用程序链接到Whatsapp或SMS消息等聊天应用程序的文本消息.

这些应用程序不接受text/html类型作为Intent类型,当我使用text/plain类型时,我的消息仅与主题一起发送而没有消息的正文.

我见过可以通过Whatsapp分享链接的应用程序,如Chrome和Dolphin Browser应用程序.

这是我的代码:

    @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"));
}
Run Code Online (Sandbox Code Playgroud)

android android-intent android-activity whatsapp

6
推荐指数
1
解决办法
8835
查看次数