我为我的应用程序定义了一个意图过滤器,如下所示:
!-- Accepts URIs that begin with "urban://success” -->
<data
android:host="success"
android:scheme="urban" />
这个深层链接似乎适用于其他浏览器,但对于 Android 版 Chrome 则不然。
我从服务器得到的答案如下所示:
urban://success?utf8=%E2%9C%93&json=%7B%22status%22%3A%...
任何帮助将不胜感激。
此致。
您需要使用注释深层链接href="android-app://"
在网页的 HTML 标记中。您可以通过添加标签并将深层链接指定为备用 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>
现在,要在应用程序中处理此意图,当您搜索某些内容时,链接也会为您提供在维基百科应用程序中打开的选项,如果您想支持两者,那么您需要修改您的 Android 应用程序。
首先,您需要在清单中添加该方案。
以下是维基百科应用程序的工作原理。
维基百科应用程序在其页面视图活动中添加了该方案,如下所示。
<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>
您需要对您的域执行相同的操作,它就会起作用。如果您需要确保您的应用程序也显示在深层链接中,请参阅link1 https://developers.google.com/app-indexing/webmasters/app and link2 https://developer.android.com/training/app-indexing/enabling-app-indexing.html#webpages
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)