深度链接在Android版Chrome浏览器中无法正常运行

编程入门 行业动态 更新时间:2024-10-11 21:26:42
本文介绍了深度链接在Android版Chrome浏览器中无法正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我为我的应用程序定义了一个意图过滤器,它是这样的:

I have an intent-filter defined for my application, which goes like this:

!-- Accepts URIs that begin with "urban://success" --> <data android:host="success" android:scheme="urban" />

此深层链接似乎适用于其他浏览器,但不适用于Android版Chrome.

This deep link seems to be working for other browsers, but for Chrome for android it does not.

我从服务器获得的答案如下:

The answer I get from the server looks like this:

urban://success?utf8=%E2%9C%93&json=%7B%22status%22%3A%...

任何帮助将不胜感激.

最诚挚的问候.

推荐答案

您需要在网页的HTML标记中使用href="android-app://"注释深层链接.您可以在每个网页的该部分中执行此操作,方法是添加标签,并将深层链接指定为备用URI.

You need to annotate the deep links using href="android-app://" in the HTML markup of your web pages. You can do this in the section for each web page by adding a tag and specifying the deep link as an alternate URI.

请参阅Wikipedia示例

<meta name="generator" content="MediaWiki 1.24wmf15" /> <link rel="alternate" href="android-app://org.wikipedia/http/en.m.wikipedia/wiki/Apollo_17" /> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php? title=Apollo_17&amp;action=edit" />

您需要在网页上添加以下代码:

You need to add below code to you webpages:

<html> <head> <link rel="alternate" href="android-app://com.example.android/example/gizmos" /> ... </head> <body> ... </body>

现在可以处理应用程序中的此意图,当您搜索某些内容时,该链接也为您提供了在Wikipedia应用程序中打开的选项,如果您想同时支持两者,那么您需要为此修改android应用程序.

Now to handle this intent in application and when you search for something and the link gives you an option for opening in wikipedia app as well, if you would like to support for both, then for that you need to modify your android app.

首先,您需要在清单中添加方案.

First, you need to add the scheme in your Manifest.

这是WikiPedia应用程序的工作方式.

WikiPedia应用程序添加了该方案,如下所示.

WikiPedia app adds the scheme, like below in their page view 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" android:pathPrefix="/wiki/" /> <data android:scheme="https" android:host="*.wikipedia" android:pathPrefix="/wiki/" /> </intent-filter> </activity>

您需要为您的域做同样的事情,它将起作用.如果您需要确保您的应用程序也显示在深层链接中,请参考 link1 和 link2

You need to do same thing for your domain and it will work. If you need to make sure that your application is also shown in deep links Refer link1 and link2

更多推荐

深度链接在Android版Chrome浏览器中无法正常运行

本文发布于:2023-11-28 18:31:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正常运行   深度   器中   链接   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!