How to override deepLinking mechanism in Android

207 Views Asked by At

I need to know if there is a way to override deepLinking mechanism to take url based action. I actually need a way to figure out whether url has query parameter or not. (Assume url doesn't have prefix) If url has query parameter i'll run app if not will redirect user to the browser)

1

There are 1 best solutions below

1
On

As quoted in the Android Developer Documentation,

<data>

Add one or more tags, each of which represents a URI format that resolves to the activity. At minimum, the tag must include the android:scheme attribute.

You can add more attributes to further refine the type of URI that the activity accepts.

android:pathPrefix

This attribute can be used to differentiate between different URL's

For example the intent filter for the URL

http://www.example.com/endpoint1

would be

<intent-filter>
<data
android:host="www.example.com"
android:pathPrefix="/endpoint1"
android:scheme="http" />
</intent-filter>

android:pathPattern

This attribute can be used to specify a regular expression for the path pattern making it suitable for path with parameters.

For example for the URL

https://www.example.com/endpoint1?param=1

android:pathPattern=".param=."