dovik
dovik

Reputation: 49

A simple HTML Anchor Link does not show-up as a link in a received email in gmail

Thanks in advance for your help.

I am developing an Android App that, as part of its core functionality, needs to send emails between users (peer-to-peer emails, not spam). These emails need to contain a link that will open the Android App upon a user-click

The problem I am having is: when I send these emails to gmail acounts, links appear as normal text rather than as links.

Here is my code

private void sendEmail(String recepientName, String recipientEmail) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);  
String aEmailList[] = {  recipientEmail };      
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);  
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Title");  
emailIntent.setType("text/html");  
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,  Html.fromHtml( 
"<!DOCTYPE html><html><body>" +
"<br>Dear " + recepientName + ",<br>" +
"Please <a href=\"myapp://" + "\"><font>click here</font></a></body></html>"));
startActivityForResult(emailIntent, EMAIL_REQUEST);
}

What should I do to make these link work in received emailsin gmail ?

Again Thanks

Upvotes: 2

Views: 2353

Answers (1)

dovik
dovik

Reputation: 49

What I discovered was that somehow (probably with great talent) I got into Google's black list. this means that Google stripped the link out of my code and the users saw it as regular text

HERE IS THE REASONING:

My link looked like this: myAppName://parameter1/parameter2/Parameter3

The prefix ("myAppName://") allows Android to identify my App and launch it as you click on the link.

HOWEVER: When this link was sent to a gmail account, Google's servers were able to identify that this was an invalid link (pretty cool that they check that ha!!) and they stripped the link out.

The solution was to use a real URL for App identification and Launch: Something like: http://myhost.com/parameter1/parameter2/Parameter3

Hope that helps

android:scheme="http" and the appropriate android:host

Upvotes: 2

Related Questions