How do i deeplink to a specific page on my Android App

情到浓时终转凉″ 提交于 2019-12-12 03:43:30

问题


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.



来源:https://stackoverflow.com/questions/38826237/how-do-i-deeplink-to-a-specific-page-on-my-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!