Mark M. |
how can I help you today?
|
Yacire |
i have a question about implicit intent; i want to send a highlighted text with a web clikable link through implicit intent but i have no idea how i can do this. I have already a text but it is not highlighted and i don't know how to add a web clikable link to my text
|
Mark M. |
extras, like EXTRA_TEXT for ACTION_SEND, support CharSequence, not merely String
|
Mark M. |
so, use a SpannableStringBuilder, or Html.fromHtml(), to create a CharSequence that has the formatting and link that you want
|
Mark M. |
then put that in the extra
|
Mark M. |
the recipient needs to also treat the result as a CharSequence, not merely a string
|
Mark M. |
and if you are not implementing the app that is responding to the Intent, you do not have any control over how it uses your CharSequence, so it might strip out the formatting
|
Yacire |
Ok, thanks. And is it possible to highlighted a text to send through implicit intent ?
|
Mark M. |
yes, I just explained that
|
Mark M. |
implicit Intent and explicit Intent make no difference here
|
Mark M. |
so long as you have the formatting in the CharSequence that you use for the extra, you are doing all that you can to have a formatted result
|
Yacire |
Ok and i can formatted the text with the Class SpannableStringBuilder ?
|
Mark M. |
that sample app highlights words in a piece of text, based on what the user enters into a search field
|
Mark M. |
it uses SpannableString, since the text does not change, just the formatting
|
Mark M. |
SpannableStringBuilder allows you to build up both the text (akin to StringBuilder) and how it is formatted
|
Yacire |
Ok it's now clear, thanks a lot !
|