VaM999 VaM999 - 6 months ago 13
Android Question

How to send text which invoves hyperlink and plain text via intent?

I'd like to know how to send hyper link and plain text together concatenated (for example share button in the application details page in play store). I have this situation, I am designing a share button in my android application, which on clicking should take the user to any texting application ( this I have done this

Intent.createChooser()
). My problem is I either get a plain text on using
Intent.setType(text/plain)
or just a hyperlink using
Intent.setType(text/html)
in which case I get only few applications to choose from (Gmail,Drive etc..). Below is my code:

Intent sharing_intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharing_intent.setType("text/*");
sharing_intent.putExtra(Intent.EXTRA_SUBJECT,"Profile Changer");
String app_link ="market://details?id=" + getPackageName();
String hyperlink="<a href=\""+ app_link +"\">"+app_link+"</a>";
String share_app_text= Html.fromHtml(hyperlink) + "\nHey! Download this application.";
sharing_intent.putExtra(Intent.EXTRA_TEXT,share_app_text);
startActivity(Intent.createChooser(sharing_intent,"Recommend via"));


Could someone please tell me how to resolve this and it done? Thanks in advance

Answer
try
{ 
  Intent i = new Intent(Intent.ACTION_SEND);  
  i.setType("text/plain");
  i.putExtra(Intent.EXTRA_SUBJECT, "Your application name");
  String sAux = "\nLet me recommend you this application\n\n";
  sAux = sAux + " "+ https://play.google.com/store/apps/details?id=getPackageName();
  i.putExtra(Intent.EXTRA_TEXT, sAux);  
  startActivity(Intent.createChooser(i, "choose one"));

}catch(Exception e){ 
   //e.toString();
}