我拼命想要实现的是在用户单击通过电子邮件发送的链接时启动我的应用程序。用户将打开他/她的 android gmail 应用程序(截至今天,我的 2.3.3 Android 手机中的版本是 2.3.6)并按照指示点击链接,以便我的应用程序可以启动并开始工作。
我已经从 android 站点的开发者角阅读了大量文档,在 SO 中也阅读了类似的问题,当然也使用了 google-fu,但没有有效的答案迄今已给出,甚至不是来自 Android 工作人员本身,他们实际上正在使用 SO 作为事实上的问答场所。
我已经尝试将此配置放入 list 文件中:
<activity android:name=".MyApp" >
<intent-filter>
<action android:name="com.my.actions.MY_CUSTOM_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity></code>
它没有用,所以我也尝试编写我的自定义方案,即使 hackbod says not to ,但这根本不起作用。 另一种选择是拥有一个自定义网站,以便可以在指定 http 方案和主机的 intent-filter 中使用“数据”标签,但这对很多不 有一个网站。
也许我遗漏了什么。我在做什么是可能的吗?即:是否可以从 gmail android 应用程序的电子邮件中编写的链接启动 Activity ?如果是,这种链接必须遵循什么结构/语法?我无法相信这会如此奇怪。在BB和iOS中使用没有任何问题。
感谢任何帮助。 提前致谢。
最佳答案
The user will open his/her android gmail app
你无法知道这一点。用户可能正在使用任意数量的电子邮件客户端。他们不会都有相同的行为,但最有希望处理 http:
链接相当一致。
but no working answer has been given to date
是的,他们有。我亲自这样做过。
Another option is to have a custom website so that a "data" tag could be used in the intent-filter specifying an http scheme and the host, but this is a show stopper for a lot of people that don't have a website.
设置网站需要几分钟和几美元。此外,他们无论如何都需要这样做,才能拥有一个网站来营销相关应用程序。如果他们负担不起,他们就无法支付 25 美元在 Play 商店上架该应用程序或其他市场的类似费用。而且,如果他们正在为企业编写此应用程序,则该企业应该已经有一个网站。而且,归根结底,如果开发人员不介意用户在没有应用程序的地方点击电子邮件时收到 404,那么 URL 不需要实际解析为 Internet 上的任何真实内容。
因此,如果这是一个“表演障碍”,那么呼吸也是。
Is is possible at all what I am doing?
是的。
If it is, what structure/syntax such link has to follow?
http://www.this-so-does-not-exist.com/something可以很好地启动 this sample app , 通过以下 <intent-filter>
:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.this-so-does-not-exist.com" android:path="/something" />
</intent-filter>
您会注意到此 URL 指向 404,表明您实际上不需要花任何钱就可以使用此技术。另请注意,此技术已在 StackOverflow 上的一些地方和其他许多地方进行了描述。
然而,intent:
即使在 HTML 电子邮件中使用,Gmail 似乎也不会选择方案。
关于android - 从电子邮件链接启动 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11031566/