我为我的应用程序定义了一个 intent-filter,它是这样的:
!-- Accepts URIs that begin with "urban://success” -->
<data
android:host="success"
android:scheme="urban" />
此深层链接似乎适用于其他浏览器,但不适用于 Chrome for android。
我从服务器得到的答案是这样的:
urban://success?utf8=%E2%9C%93&json=%7B%22status%22%3A%...
我们将不胜感激。
最好的问候。
最佳答案
您需要在网页的 HTML 标记中使用 href="android-app://"
注释深层链接。您可以在每个网页的部分中通过添加标记并将深层链接指定为备用 URI 来执行此操作。
参见维基百科示例
<meta name="generator" content="MediaWiki 1.24wmf15" />
<link rel="alternate"
href="android-app://org.wikipedia/http/en.m.wikipedia.org/wiki/Apollo_17" />
<link rel="alternate"
type="application/x-wiki" title="Edit this page" href="/w/index.php? title=Apollo_17&action=edit" />
您需要在您的网页中添加以下代码:
<html>
<head>
<link rel="alternate"
href="android-app://com.example.android/example/gizmos" />
...
</head>
<body> ... </body>
现在要在应用程序中处理此 Intent ,当您搜索某些内容时,链接也会为您提供在维基百科应用程序中打开的选项,如果您希望同时支持这两种应用程序,那么为此您需要修改您的 Android 应用程序.
首先,您需要在 list 中添加方案。
维基百科应用的工作原理如下。
WikiPedia 应用在其页面浏览 Activity 中添加了该方案,如下所示。
<activity android:name=".page.PageActivity" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="*.wikipedia.org"
android:pathPrefix="/wiki/" />
<data
android:scheme="https"
android:host="*.wikipedia.org"
android:pathPrefix="/wiki/" />
</intent-filter>
</activity>
关于android - 深层链接在 Chrome for Android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25192778/