Question

I want to open my Android app for a specific link not for the specific host so that whenever user types the url in browser my app should be shown in Open With options.

I have already got success in opening my app from browser link.

For e.g:

If user types: www.abc.com app must not be shown in Open with options. But if user types or clicks www.abc.com/video app must be shown.

I have tried diffrent combination of following but none of them works.

<data android:pathPrefix="www.abc.com" android:pathPattern=".*" android:pathPrefix="/video/" android:scheme="http" />

It shows me my app even if I have typed abc.com in web browser. But what i want is that my application should only be visible if the user typed exact url i.e. www.abc.com/video

Was it helpful?

Solution 2

What i Understands after applying all the combinations of

<data android:pathPrefix="www.abc.com" android:pathPattern=".*" android:pathPrefix="/video/" android:scheme="http" />

is that:

1.) Browser throws intent for the url part before the /(slash) operator. For e.g: If I write www.abc.com/terms, Browser will throw intent for www.abc.com. similary It will also check for www.abc.com/videos, www.abc.com/xyz, abc.com/, abc.com/videos and throws intent.

Now, Its our responsiblity to check other params in the incoming url and provide checks for the url we want to handle.

In my case, I have added check for second parameter videos if it contains, else show the home screen for the app.

OTHER TIPS

From Android docs:

Each of these attributes is optional, but they are not independent of each other: For an authority to be meaningful, a scheme must also be specified. For a path to be meaningful, both a scheme and an authority must be specified.

Then you should use:

android:scheme="http" android:host="www.abc.com" android:path="/video"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top