12

I added a deep linking to my Android app this way:

<activity
        android:name=".views.DeepLinkingActivity"
        android:exported="true">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:scheme="https"
                android:host="example.com"/>
        </intent-filter>
    </activity>

When I click on https://example.com I get redirected to the web site.

When I change android:scheme="https" to android:scheme="appscheme" it works and it redirects me to my app.

How to force my app to be opened via https scheme?

UPDATE

I added a subdomain and it still doesn't work.

<activity
        android:name=".views.DeepLinkActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="https"
                android:host="www.example.ru"/>
        </intent-filter>
    </activity>
Rainmaker
  • 10,294
  • 9
  • 54
  • 89

7 Answers7

4

Thanks to veritas1 I removed android:autoVerify="true" from https-scheme. I also changed the scheme from https to http. (You can read about autoVerify).

So, currently have two different schemes:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="your-site.com"
        android:pathPrefix="/"
        android:scheme="http"
        />
</intent-filter>
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="your-site.com"
        android:pathPrefix="/"
        android:scheme="myapp"
        />
</intent-filter>

When clicking on a link myapp://your-site.com/... an application will be opened. When clicking on http://your-site.com/... Chrome browser will offer to open in the application or another browser, while other mobile browsers ignore this and try to open themselves.

UPDATE

See https://stackoverflow.com/a/60342565/2914140 for App Linking.

CoolMind
  • 26,736
  • 15
  • 188
  • 224
3

Hi please use the following data and try also refer this doc

<intent-filter>
                <data
                    android:scheme="ou unique scheme(appname,package name)" />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

OR

  <data
                android:scheme="you unique scheme(appname,package name)"
                android:host="www.example.ru"/>
Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52
1

You refer to deep linking but android:autoVerify="true" is used for App linking, so the domain example.com (which you don't own?) is going to get checked for a digital asset links json file. See https://developer.android.com/training/app-links/index.html

For your test to work I'd suggest removing android:autoVerify="true" and adding a subdomain to the host e.g. android:host="www.example.com"

veritas1
  • 8,740
  • 6
  • 27
  • 37
  • I changed android:host="example.com" to android:host="www.example.com", deleted autoVerify, but no result, did i miss somth? – Rainmaker Oct 11 '17 at 06:42
  • Now it says that connection is not secure. By the way I've added asset links file to the server according to your link but still no result – Rainmaker Oct 11 '17 at 06:54
  • Any idea? Do you have at least one app which work with https? – Rainmaker Oct 11 '17 at 07:28
  • Where does it say "connection is not secure"?, If it works correctly, you should be presented with the disambiguation dialog to select which app you would like to open the link, I have tested with and works fine. You may have added the asset links file your app server, but it's `https://example.com/.well-known/assetlinks.json` that's going to be resolved as `example.com` is the domain your trying to verify. – veritas1 Oct 11 '17 at 07:36
  • I edited mt question like you said, look at it, but it doesn't work – Rainmaker Oct 11 '17 at 07:45
  • Where has `android:host="www.example.ru"` come from? Just make sure the clickable link matches the host specified in the manifest. – veritas1 Oct 11 '17 at 07:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/156440/discussion-between-veritas1-and-rainmaker). – veritas1 Oct 11 '17 at 08:28
0

Try this

<activity
             android:name=".views.DeepLinkingActivity"
        android:exported="true">


           <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="open"
                    android:scheme="example" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="example.com"
                    android:pathPrefix="/"
                    android:scheme="http" />
            </intent-filter>
           <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="example.com"
                    android:pathPrefix="/"
                    android:scheme="https" />
            </intent-filter>
        </activity>
J Ramesh
  • 548
  • 4
  • 11
0

Just use http. Don't know when the implementation is changed.

But I just tested that using http will make both http and https work.

So change you intent filter by:

<intent-filter android:autoVerify="true">

<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
    android:scheme="http"
    android:host="example.com"/>

</intent-filter>
roytornado
  • 334
  • 3
  • 4
0

youe can also add to it

sub.example.com

<intent-filter android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="example.com" />
                <data android:scheme="app" android:host="com.example.example" />
            </intent-filter>
eng mohamed emam
  • 549
  • 6
  • 13