本文介绍了深度链接在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.org/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.org"
    android:pathPrefix="/wiki/" />
<data
    android:scheme="https"
    android:host="*.wikipedia.org"
    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浏览器中无法正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 20:42