How do I pass a Gmail hyperlink to Intent ACTION_SEND?

Perhaps this question has already been asked or duplicated by another question, but I did not have any solution for my search. Here are the links that I followed my question: Link1 Link2

Actually, my question is about sharing HTML text in the default intent of Android using ACTION_SEND. When I try to create a hyperlink to a URL with a different value, then it shows the plain text of the value. This is not available for reference.

Here is how I do it:

Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); String link = "https://www.android.com/"; String linkValue = "Click Me"; String body1 = "<a href=\"" + link + "\">" + link+ "</a>";//I don't want this String body2 = "<a href=\"" + link + "\">" + linkValue + "</a>";//This is not working intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body2)); startActivity(Intent.createChooser(intent, "Share With")); 

For body2: When I exchange text using Gmail, then in the letter the hyperlink text will look like plain text. Just "Click Me". I also tested it on a desktop browser. But there is the same thing. I checked this text in the Inspect Element (you can get the Inspect Element on the browser page, for example: Right-click on the browser page β†’ In the pop-up window, click below. Inspect OR refer Check element ) and found that there was no tag for the hyperlink text.

For body1: It works, and I got the URL as a hyperlink in the email, but I got the URL as a hyperlink. I do not want to show the same URL in email, and not as body2 format. This format can be achieved by directly exchanging URLs in a body that does not require a tag.

enter image description here

So finally, my search: is there any way in Android to exchange hyperlink text with a different hint value and not a link (URL).

+8
android html android-intent hyperlink gmail
source share
6 answers

I suggest you use a string resource instead of a Java string, as a rule, and good practice, and you do not have to avoid "too." And with the HTML data, you have to wrap it in CDATA.

XML:

 <string name="readyandroid"><![CDATA[<a href="https://readyandroid.wordpress.com/">readyandroid</a>]]></string> 

in Java, replace body2 with:

 String body2 = getString(R.string.readyandroid); 

Then try to pass it on to your intention and send it by e-mail, it should be the appropriate hyperlink as you would like.

+1
source share

What you do in the body is absolutely correct.

But Gmail reads the additional android.intent.extra.TEXT as a string.

In fact, you are making a function request / reporting an error.

0
source share
  android:autoLink="web|email" 

Please add this code to textview xml. It will be directly linked to the gmail link.

0
source share

I do not think you can do this by email. Send an email without intention Make an email client to send email. This will support the HTML tag.

link plz

http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android

0
source share

After you add String to the add-on, it will lose its attributes as Spanned . If you send it as html, it can be resolved by some applications and shown as you wish. As a rule, you simply put plain text in the Bundle your Intent , and each application interprets it as it wishes, so there is no solution to send it as html and force the application to display it as html.

On the other hand, if you know which applications you are going to use through sharing, you can read its documentation and check whether it allows you to send hyperlinks through the intent ACTION_SEND.

You can tell the recipient that your text type is intent.setType("text/html") , perhaps the behavior of some applications depends on it.

0
source share

Yes, I decided to solve this problem. Thanks, @Faraz.

This is my response code since I created a tag string in string.xml

  <string name="link_to_google_map"><![CDATA[<a href="http://maps.google.com/maps?&z=10&q=%1$s+%2$s">LINK TO GOOGLE MAP</a>]]></string> 

And my code is similar to this one that works great for tag sharing in android:

  Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); String shareText = "Thank you for using the ReadyAndroid App" + "<br />" + "Name : " + "ReadyAndroid"; shareText += "<br />" + "Address : " + "https://readyandroid.wordpress.com/ <br />Mandawa, Jhunjhunu, Rajasthan 333704"; String mapLocation = String.format(getString(R.string.link_to_google_map), 28.0500, 75.1487); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(shareText+mapLocation)); startActivity(Intent.createChooser(intent, "Share with")); 
0
source share

All Articles