From my app i want to share some detail via email and all other sites. Following is my code to open email
private void email()
{
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822") ;
i.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
i.putExtra(Intent.EXTRA_SUBJECT,i0+" hiiiiiiiiii");
i.putExtra(Intent.EXTRA_TEXT,**sharetext**);
startActivity(Intent.createChooser(i, "Select application"));
}
Following is my sharetext
"hi friends please visit my website for http://www.xxxxxxxx.com/apply "
Now i want the url in my share text to be viewed in a blue line, so that when the user clicks it i want to open the webpage.
But in my app the url seems to be normal one. How to do this....
You can use SpannableStringBuilder to build text with embedded url link. Here is an example:
private void email()
{
String url = "http://www.xxxxxxxx.com/apply";
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("hi friends please visit my website for");
int start = builder.length();
builder.append(url);
int end = builder.length();
builder.setSpan(new URLSpan(url), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822") ;
i.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
i.putExtra(Intent.EXTRA_SUBJECT,"hiiiiiiiiii");
i.putExtra(Intent.EXTRA_TEXT, builder);
startActivity(Intent.createChooser(i, "Select application"));
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With