How do I pass data through deep binding?
I have a list of suggestions in my application and there is a share button for each list item. I am using a deep link to open my app's detailed offer activity when any user clicks on a shared link. I'm in a situation where my detail page activity is triggered when someone clicks on a link, But how can I know that it offers detailed actions to show when someone clicks on a shared link.
source to share
The manifest file will remain the same as mentioned in this link https://developer.android.com/training/app-indexing/deep-linking.html
But you can provide additional data in the link you send to the user like www.example.com/gizmos?key=valueToSend
then in action you can do something like
Uri data = intent.getData();
data.getQueryParameter("key");
source to share
Let's say you create a separate share link for each item. You can send some parameters along with the deep link url and then get them in the app. Any type of identifier would be sufficient. (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 this example, if the links in the app are here, you can get your intent in the corresponding activity (here: com.example.android.GizmosActivity) and extract information from it.
source to share