如何使用链接发送电子邮件,打开Android应用 [英] How to send email with link to open Android application

查看:155
本文介绍了如何使用链接发送电子邮件,打开Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创造了一些code表示邮件的HTML电子邮件发送到指定的地址。该邮件中包含类似下面的链接:

 < A HREF =crystalcloud://机器人4567>点击验证帐户< / A>
 

我被发送到我的Gmail帐户测试这一点。出于某种原因,当我收到邮件,它不会让我点击链接。如果我把网页中的链接,我的应用程序启动后就好了。

有没有一些特别的东西我必须做的就是此链接显示在电子邮件,或Gmail的那张只是阻止这些类型的链接?反正是有解决这个问题,在Gmail?

编辑:我的code新增片段

code发送链接:

 的MimeMessage消息=新的MimeMessage(会议);
    message.setFrom(新网际(从));
    message.addRecipient(Message.RecipientType.TO,新的网际(EMAILADDRESS));
    message.setSubject(新晶云用户);
    message.setContent(感谢您创建一个新的Crystal Cloud帐户< BR>< A HREF = \!crystalcloud://机器人4567>点击验证帐户< / A>中,text / html的? ;字符集= UTF-8);
    交通运输= session.getTransport(SMTP);
    transport.connect(主机,从,通);
    transport.sendMessage(消息,message.getAllRecipients());
    transport.close();
 

Android的code向意图作出回应:

 <意向滤光器>
            <作用机器人:名称=android.intent.action.VIEW/>
            <类机器人:名称=android.intent.category.BROWSABLE/>
            <类机器人:名称=android.intent.category.DEFAULT/>
            <数据机器人:计划=crystalcloud/>
        &所述; /意图滤光器>
 

解决方案

这是与Android的电子邮件客户端的问题,他们不显示的链接是可以点击的,除非它们是HTTP或HTTPS。

我的解决方案是使用一个HTTP方式打开我的应用程序:

 <数据机器人:计划=HTTP机器人:主机=com.company.app机器人:端口=3513/>
 

这工作,但恼人的,因为它提示在浏览器或应用程序中打开应用程序的用户。 另一个解决方案是有一个链接到一个网站,然后做了一个JavaScript重定向到您的应用程序,虽然这可能会导致更多的问题。

I have created some code that emails an html email to a given address. The email contains a link like the following:

<a href="crystalcloud://android?4567">Click to validate account</a>

I was testing this by sending it to my gmail account. For some reason, when I receive the email, it will not let me click on the link. If I put this link in a web page, my application starts up fine.

Is there something special I have to do to get this link to show up in an email, or goes gmail just block these kind of links? Is there anyway to get around this issue in gmail?

EDIT: Added snippets of my code

Code to send link:

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

Android code to respond to intent:

        <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>

解决方案

This is a problem with the android email clients that they don't show links as clickable unless they are http or https.

My solution was to use a http scheme to open my app:

<data android:scheme="http" android:host="com.company.app" android:port="3513" />

This works but in annoying because it prompts the user to open the app in either the browser or your application. Another solution is to have a link to a website that then does a javascript redirect to your app though this can cause more problems.

这篇关于如何使用链接发送电子邮件,打开Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆