How do i deeplink to a specific page on my Android

2019-09-07 01:41发布

问题:

I'm trying to deeplink to a specific page on my Android app.

This is what i've tried:

DeepLinkingTest://?screen=ResetResponse

but it just opens the app home page

Update:

I've just tried:

<activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <data android:scheme="deeplinkingtest"
                      android:host="resetresponse"/>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

but still opening on home page

回答1:

Add intent filter for the activity that you want to open via deep link to its definition in the AndroidManifest.xml. Here is an example:

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_title_viewgizmos">
        <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.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- note that the leading "/" is required for pathPrefix-->
        <!-- Accepts URIs that begin with "example://gizmos” -->
        <data android:scheme="example"
              android:host="gizmos" />

    </intent-filter>
</activity>

In this example, GizmosActivity is the activity you want to start via deep link.