"Or" Intent 过滤器中的路径模式

"Or" in pathpattern in Intent filter

我怎么能说 link 必须是“https://www.example.org/kk/article/Details" or "https://www.example.org/ru/article/Details" or "https://www.example.org/en/article/Details

需要找出下面代码中路径模式中的 "kk or en or ru" 部分

   <intent-filter android:label="login">
    <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="https"
                        android:host="www.example.org"
                        android:pathpattern="/kk or en or ru/article/Details" />
                </intent-filter>

您需要定义所有类型,即您需要为每个路径值指定数据标记。

<intent-filter android:label="login">
    <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
android:host="www.example.org" />
android:pathpattern="/kk/article/Details" />
android:pathpattern="/en/article/Details" />
android:pathpattern="/ru/article/Details" />

android:pathpattern 不支持普通正则表达式所支持的所有规则。有关详细信息,请阅读 this。这样做的唯一方法是这样的:

<intent-filter android:label="login">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https" android:host="www.example.org" android:pathpattern="/kk/article/Details" />
    <data android:scheme="https" android:host="www.example.org" android:pathpattern="/en/article/Details" />
    <data android:scheme="https" android:host="www.example.org" android:pathpattern="/ru/article/Details" />
</intent-filter>

这是一个老问题,但可能对新用户有用。有一个更简单的解决方案是:

<intent-filter android:label="login">
    <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data 
          android:scheme="https"
          android:host="www.example.org" 
          android:pathpattern="/.*/article/Details" />
</intent-filter>