ela*_*zaa 6 android android-intent android-activity 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)
@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"));
}
Run Code Online (Sandbox Code Playgroud)
在这里,我只是更改emailIntent.setType("text/plain");此行的位置即可 。您可以在邮件应用程序正文电子邮件应用程序主体中获得链接。但是在这里,您只能在邮件应用程序中获得主题文本,而在邮件应用程序中无法获得主题文本,但是您可以在正文中获得链接,从而实现目标...
而已...
| 归档时间: |
|
| 查看次数: |
8835 次 |
| 最近记录: |