2

在此先感谢您的帮助。

我正在开发一个 Android 应用程序,作为其核心功能的一部分,它需要在用户之间发送电子邮件(点对点电子邮件,而不是垃圾邮件)。这些电子邮件需要包含一个链接,该链接将在用户单击时打开 Android 应用程序

我遇到的问题是:当我将这些电子邮件发送到 gmail 帐户时,链接显示为普通文本而不是链接。

这是我的代码

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);
}

我应该怎么做才能使这些链接在收到的 gmail 电子邮件中起作用?

再次感谢

4

1 回答 1

2

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

于 2012-12-02T19:14:38.683 回答