Android:应用链接 - 仅支持某些路径?

Jon*_*Jon 5 android uri url-scheme applinks digital-assets-links

我想为我的应用设置应用链接,但仅限于它在某些路径上有效.换句话说,在我的清单中:

<intent-filter  android:autoVerify="true">
<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="www.mydomain.com/[mypath]" />
<data android:scheme="https" android:host="www.mydomain.com/[mypath]" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

我不希望每个拥有我的域名的网址都能打开应用程序 - 他们可以照常在浏览器中打开.我只想要在应用程序中打开包含特定子路径的URL.这种模式是允许的还是应用程序链接的"全有或全无"?

链接到开发人员文档:http: //developer.android.com/training/app-links/index.html

cra*_*aya 7

您可以拥有特殊路径,但不能/不应将它们附加到主机.

你应该有

<data android:scheme="https" android:host="www.mydomain.com" />
Run Code Online (Sandbox Code Playgroud)

从那里你可以使用android:path android:pathPattern或android:pathPrefix来创建特殊模式.

例如,

<data android:scheme="https" android:host="www.google.com" android:path="/en/index.html"/>
Run Code Online (Sandbox Code Playgroud)

只会抓住网址" https://www.google.com/en/index.html "

  • 如果您的路径是通配符(例如 `/profile/*`),那么您应该使用 `android:pathPattern="/profile/.*"` 按照 /sf/answers/3037754331/ 。请注意,它是 android 想要的格式的`.*`。 (2认同)