我想使用ACTION_SEND意图从 Android 应用程序共享格式化文本,我发现我可以使用该标签。它可以很好地与电子邮件共享 HTML 文本,但如果我尝试与 Facebook、Twitter、Hangout 共享它,则不会显示任何文本。当然,他们无法解释 HTML 代码。如何使用格式化的代码处理不同的共享方式?这是代码:
Spanned shareBody = Html.fromHtml(context.getString(R.string.suggest_text));
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, context.getString(R.string.suggest_subject));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, context.getString(R.string.share_with)));
这是 strings.xml 中的值
<string name="suggest_text">
<![CDATA[
<p>Hey,</p>
<p>good morning</p>
<p><a href="http://www.someurl.bla">Click here</a>
]]>
</string>