如何发送带有链接的电子邮件以打开Android应用程序

Nic*_*nks 9 java gmail android android-intent

我创建了一些代码,通过电子邮件将html电子邮件发送到给定地址.该电子邮件包含以下链接:

<a href="crystalcloud://android?4567">Click to validate account</a>
Run Code Online (Sandbox Code Playgroud)

我通过将其发送到我的Gmail帐户来测试它.出于某种原因,当我收到电子邮件时,它不会让我点击链接.如果我将此链接放在网页中,我的应用程序就可以正常启动.

有什么特别的东西要让这个链接显示在电子邮件中,或者gmail只是阻止这些链接吗?无论如何在gmail中解决这个问题?

编辑:添加了我的代码片段

代码发送链接:

    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailAddress));
    message.setSubject("New Crystal Cloud User");
    message.setContent("Thank you for creating a new Crystal Cloud account!<br><a href=\"crystalcloud://android?4567">Click to validate account</a>", "text/html; charset=utf-8");
    Transport transport = session.getTransport("smtp");
    transport.connect(host, from, pass);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
Run Code Online (Sandbox Code Playgroud)

用于响应意图的Android代码:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="crystalcloud" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

sko*_*lis 15

这是Android电子邮件客户端的问题,除非他们是http或https,否则他们不会将链接显示为可点击.

我的解决方案是使用http方案打开我的应用程序:

<data android:scheme="http" android:host="com.company.app" android:port="3513" />
Run Code Online (Sandbox Code Playgroud)

这有效,但很烦人,因为它会提示用户在浏览器或应用程序中打开应用程序.另一种解决方案是拥有一个指向网站的链接,然后将javascript重定向到您的应用,尽管这可能会导致更多问题.