I want to catch the view action of my site url and an specific path in my site.
http://examplesite.com/
http://examplesite.com/detail/nameOfProduct
I want the main activity to be open for the first url so I used:
<data
android:host="examplesite.com"
android:scheme="http"/>
and for the second url I want the detail activity to be opened so i put:
<data
android:host="examplesite.com"
android:pathPrefix="/detail"
android:scheme="http"/>
now the problem is when the first URL is called in an intent both activities are shown to user to choose, while I just want the main activity to be shown. how can I solve this problem. what did I do wrong ?
The reason you're facing this problem is because the first intent filter matches
http://examplesite.com*
.Using pathPrefix="/" wouldn't work either as that would catch:
http://examplesite.com/*
Now the solution to your problem is to replace this:
With:
I recommend you to register only main activity and parse there the url, if it leads to /detail, launch detail activity
You can try this alternate way, Make a Separate activity for appindexing so that add intent filter for that particular activity, so only this activity will pointed to launch into your app.
After landing in this Activity
Note: you can also use Regex to split down the uridata(url received) and to match it perfectly and can make condition depending upon your need.