How to exclude URLs with Android Intent Filters?

2019-06-26 03:08发布

问题:

I saw some intent filters like this one.

<data android:scheme="http" 
      android:host="m.facebook.com" 
      android:pathPattern=".*"/>

Facebook app throws URLs like

http://m.facebook.com/l.php?u=http%3A%2F%2Fyoutu.be%2FBsKtRwSyLmM&h=9AQF5nU03&s=1

I want to open those urls that contain youtu.be but NOT user (as I want to open videos in the app not user profiles).

回答1:

I have been looking for something similar, and apparently you can only filter the actual path (in this case "l.php") and not the query string (u=http%3A...).

Here is a similar questions: intent filter pathPrefix with question mark

And a workaround (works only if you are looking for references to your own page): Android Browser Facebook Redirect Does Not Always Trigger Intent for URL