开发者

intent filter pathPrefix with question mark

I want to set up an intent filter to handle urls like: http://mysite.com/?action=delete&id=30492

I've tried setting up my intent-filter as follows:

<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:scheme="http" android:host="mysite.com" android:pathPrefix="/?action="/>
</intent-filter>

However, this doesn't work, and my app is not recognized as being able to handle the URL. I know that it's because I'm doing something wrong with my pathPrefix because when I remove the pathPrefix it works. I also know that it's related to having the question mark in there because if I remove the question mark from the URL and the pathPrefix, it works.

Do I need to escape the question mark in some way? I tried escaping with a slash (android:pathPrefix="/\?action=") but that doesn't work either.

How can I get this intent filter开发者_C百科 to work?


The query string (?action=... in your example) is not part of the path. AFAIK, you cannot filter on query strings.


Since Api 19 you can use sspPattern:

android:sppPrefix="//mysite.com/?action="

Do not forget remove android:host and android:pathPrefix


As mentioned by @orgazm-pionerki android:ssp seems to fix this issue. I lot couple of hours today. With a link that look like https://mywebsite.com/?param1=value1&param2=value2 I had to set this data in manifest :

<data android:scheme="https" />
<data android:host="mywebsite.com" />
<data android:sspPattern="/?param1=.*&amp;param2=.*" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜