0

I want to share a formatted text from Android application using ACTION_SEND intent and I've found I can use the tag. It works well sharing the HTML text with email, but if I try to share it with Facebook, Twitter, Hangout, no text is showed. Of course they can't interpret the HTML code. How can I handle the different sharing ways with the code formatted ? This is the code:

    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)));

and this is the value in 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>
andreasperelli
  • 962
  • 2
  • 9
  • 35

1 Answers1

1

Try like this

shareIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
    .append("<p><b>Hey,</b></p>")
    .append("<small><p>good morning</p></small>")
    .toString())
);
Remees M Syde
  • 2,691
  • 1
  • 17
  • 41