安卓:使用意图分享纯文本(所有消息应用程序) [英] Android: Share plain text using intent (to all messaging apps)
本文介绍了安卓:使用意图分享纯文本(所有消息应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个意图分享一些文字:
I'm trying to share some text using an intent:
Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_TEXT, "TEXT");
和与选择器变形:
startActivity(Intent.createChooser(sms, getResources().getString(R.string.share_using)));
它的作品!但仅限于电子邮件应用程序。
我需要的是一个总的意图所有消息应用程序:电子邮件,短信,即时通讯(的WhatsApp,Viber的,Gmail的,短信...)
尝试使用 android.content.Intent.ACTION_VIEW
没有任何帮助...
it works! but only for email app.
what I need is a general intent for all messaging app: emails, sms, IM (Whatsapp, Viber, Gmail, SMS...)
tried using android.content.Intent.ACTION_VIEW
and tried using i.setType("vnd.android-dir/mms-sms");
nothing helped...
(vnd.android-DIR / MMS短信
通过短信共享而已!)
("vnd.android-dir/mms-sms"
shared using sms only!)
推荐答案
使用code为:
String shareBody = "Here is the share content body";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));
这篇关于安卓:使用意图分享纯文本(所有消息应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文