问题
I am having a list of offers in my application and there is a share button on every list item.I am using deep link to open a offer detail activity of my application when any user clicks on the shared link.i am in a situation that my detail page activity is being triggered when someone clicks the link ,But how can i know ,which offer detail activity to show when some one clicks on the shared deep link .
回答1:
The manifest file will remain same as specified in this link https://developer.android.com/training/app-indexing/deep-linking.html
But you can provide the extra data in the link you send to the user as www.example.com/gizmos?key=valueToSend
then in the activity you can do something like
Uri data = intent.getData();
data.getQueryParameter("key");
回答2:
Supposing that you generate a separate share link for each item. You could send some parameters along with the deep link URL and then receive them in the App. Any kind of an ID would suffice. (Source: this)
<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>
Taking up this example, if the app deep links here, you can receive your intent in the corresponding activity (Here: com.example.android.GizmosActivity) and extract information from there itself.
来源:https://stackoverflow.com/questions/31889744/how-to-pass-data-through-deep-linking