Android的深度链接到一个应用程序 [英] Android deep linking into an app

查看:215
本文介绍了Android的深度链接到一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可以通过它在与我的应用程序安装会自动在我的应用程序打开正确的页面在Android设备上打开电子邮件发送的链接。

I am trying to create a link that can be sent via email which when opened on an android device with my app installed will automatically open the correct page in my app.

我已经得到了这部分工作在几个不同的方式,但已经发现,我想知道如果任何人有解决方案的几个问题。

I have gotten this partially working in a few different ways but have found a few problems that I was wondering if anyone has solutions to.

尝试1:使用自定义方案:MyApp的:// someItem。这工作,但一些电子邮件应用程序不把它当作一个环节,因为它不是HTTP。有没有办法强制应用程序把它当作一个有效的链接? Gmail中的例子。

Attempt 1: Using a custom scheme: myapp://someItem. This works but some email applications do not treat this as a link as it is not http. Is there a way to force applications to treat it as a valid link? gmail for example.

尝试2:使用与宿主的HTTP链接: HTTP://com.myapp/someItem 。这工作很好,但我的应用程序最终注册来处理所有的HTTP连接,它是不理想的。

Attempt 2: Using a http link with a host: http://com.myapp/someItem. This works as well but my app ends up registered to handle all http links which is not ideal.

尝试3:使用HTTP链接与主机和端口: HTTP://com.myapp:2345 / someItem 。这是我的当前的解决方案,唯一的缺点是该链接的打开时它仍然给在浏览器中打开链接的选项。有没有办法阻止浏览器尝试打开链接?

Attempt 3: Using a http link with host and port: http://com.myapp:2345/someItem. This is my current solution with the only drawback being that when the link is opened it still gives the option of opening the link in a browser. Is there a way to stop the browser attempting to open my links?

有没有人有办法让这将被视为链接所有应用程序,并在浏览器中打开它们时被忽略的链接?

Does anyone have a way to make links that will be treated as links by all applications and also be ignored by the browser when opening them?

推荐答案

这个技术实际上似乎是工作在Android从我可以告诉:

This technique actually seems to be working on Android from what I can tell:

http://mobile.dzone.com/news/custom-url-方案 - PhoneGap的

我还没有尝试过在实际生产中的应用程序还没有,所以你的里程可能会有所不同。我所做的就是用创建一个隐藏的iframe,并试图将位置设置为自定义URL方案,并要求从onload事件的函数文档的技术。我到目前为止看到的(我只测试了它的2.2和2.3设备)是,如果我有一个应用程序安装处理自定义方案的应用程序将启动,如果没有该页面将呈现。

I haven't tried it in a real production app yet, so your mileage may vary. What I've done is use that technique of creating a hidden iframe and attempting to set the location to the custom url scheme, and call the function from onload for the document. What I've seen so far (I've only tested it out on 2.2 and 2.3 devices) is that if I have an app installed that handles the custom scheme the app will launch, and if not the page will render.

比较干净单一的URL来覆盖这两种情况下,并不会破坏之类的网址Twitter的股份。一个真正的量产版可能只做隐藏的iframe探头,如果该请求是来自东西,看起来像有可能支持应用程序,以减少不兼容的桌面行为风险的平台来了。

Relatively clean single URL to cover both cases, and doesn't ruin things like Twitter shares of the URL. A real production version might only do the hidden iframe probe if the request is coming from something that looks like a platform that might support the application to reduce the risk of incompatible desktop behavior.

这篇关于Android的深度链接到一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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