Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deep Link not working in Chrome for Android

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" />

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%...

Any help will be appreciated.

Best regards.

like image 612
FeleMed Avatar asked Aug 07 '14 21:08

FeleMed


People also ask

How do I enable deep link on Android?

Android Studio makes it very easy to test deep links. Click Run > Edit Configurations to edit the configuration of the project. Open the General tab at the top and enter the URI in the Deep Link field in the Launch Options section.


1 Answers

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.

See example for 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>

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.

Here is how WikiPedia app works.

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>

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

like image 83
AnkitSomani Avatar answered Nov 03 '22 01:11

AnkitSomani