Reputation: 22038
I've registered the following intent filter in my app's manifest:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="m.mycompany.de"
android:pathPattern="/app/list"
android:scheme="http" />
</intent-filter>
And created a simple html page to test if the app opens correctly:
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>
A Small Hello
</TITLE>
</HEAD>
<BODY>
<a href = "http://m.mycompany.de/app/list?param1=178¶m2=87294">Click</a>
</BODY>
</HTML>
On some devices (e.g. Nexus 5 running Android 5.1) clicking the link opens my app as expected, on other devices (e.g. Nexus 6 also running 5.1) the PlayStore (my app's page) is opened instead of my app.
Any ideas what the problem might be?
EDIT: Strangely, this 'bug' is gone when simplifying the URL to :
http://m.mycompany.de/list?param1=178¶m2=87294
and my intent filter to
<data
android:host="m.mycompany.de"
android:pathPattern="/app"
android:scheme="http" />
which is not an option though because I don't have control over the URLs for my live app.
Upvotes: 27
Views: 5239
Reputation: 236
You can use pathprefix instead of android:pathPattern
<data
android:host="m.mycompany.de"
android:pathPrefix="/app/list"
android:scheme="http" />
and in second case when you use below url,
http://m.mycompany.de/list?param1=178¶m2=87294
the data tag should be
<data
android:host="m.mycompany.de"
android:pathPrefix="/list"
android:scheme="http" />
Upvotes: 4
Reputation: 4710
As I see, you use data section's pathPattern parameter in wrong direction.
According to Google docs:
The pathPattern attribute specifies a complete path that is matched against the complete path in the Intent object.
So you need to use pathPrefix instead of pathPattern:
The pathPrefix attribute specifies a partial path that is matched against only the initial part of the path in the Intent object.
Or just discard path and use only host and scheme like that:
<data
android:host="m.mycompany.de"
android:scheme="http" />
P.S. Additionally note Mimmo Grottoli comment for original message.
Upvotes: 0