Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i searched a lot and i read many answers but unfortunately i didn't manage to make it work.

I am testing deep link on my app and i can not make custom scheme url work on click.

My Manifest code is :

   <activity android:name=".ui.activities.home.HomeActivity"
            android:exported="true"
            android:launchMode="singleTask">
    <!-- for http links -->
        <intent-filter android:label="testHttpDeepLink">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "http://www.myapp.com/test” -->
            <data android:scheme="http"
                android:host="www.myapp.com"
                android:pathPrefix="/test" />
        </intent-filter>
            <!-- for app links -->
        <intent-filter
            android:label="testAppDeepLink">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "myapp" -->
            <data android:scheme="myapp"
                android:host="*"/>
    </activity>

When i am trying to test it on studio terminal the second format works fine. So if i write

adb shell am start -a android.intent.action.VIEW -d "myapp://test" 

app home activity opens correct. But when i try to open it from a link it does not work. For example i send an email to myself with possible formats, for example

1 -> www.myapp.com/test
2 -> myapp://test

The first works fine but the second not. It shows message error: net::ERR_UNKNOWN_URL_SCHEME when i click to the url. Only if i press long click and select open then drives me to app home activity.

question from:https://stackoverflow.com/questions/66061885/android-custom-scheme-deep-link-does-not-work-on-click

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
416 views
Welcome To Ask or Share your Answers For Others

1 Answer

* is not a valid value for a android:host. Simply remove it and it will work.

Also, this method is heavily reliant on the app handling the url in the first place. If your browser doesn't let the system handle non-http scheme, you won't be able to make it work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...