Intent filter browser android:pathPrefix url param

2019-05-12 11:43发布

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条回答
时光不老,我们不散
2楼-- · 2019-05-12 12:35

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.

查看更多
登录 后发表回答