Intent filter browser android:pathPrefix url parameter

无人久伴 提交于 2019-12-10 09:46:56

问题


So I'd like my activity to catch when an intent (browser) calls the link:

http://host/info?username=samplename 

and not when:

http://host/info?username=noname 

Here is my code coming from AndroidManifest.xml

<intent-filter>
   <action android:name="android.intent.action.VIEW"></action>
   <category android:name="android.intent.category.DEFAULT"></category>
   <category android:name="android.intent.category.BROWSABLE"></category>\
   <data android:host="host" android:pathPrefix="/info?username=samplename" android:scheme="http"></data>
</intent-filter>

I have it working for a simple prefix such as android:pathPrefix="/info" But I have problem with the character ? I tried using \? but doesn't work http://developer.android.com/guide/topics/manifest/data-element.html#path

Anybody would have any idea?

Thanks


回答1:


Have you tried \\?

Because '\' is used as an escape character when the string is read from XML (before it is parsed as a pattern), you will need to double-escape: For example, a literal '' would be written as "\" and a literal '\' would be written as "\\". This is basically the same as what you would need to write if constructing the string in Java code.



来源:https://stackoverflow.com/questions/8090441/intent-filter-browser-androidpathprefix-url-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!