【问题标题】:Android: app linking - supporting only certain paths?Android:应用程序链接 - 仅支持某些路径?
【发布时间】:2016-04-02 15:07:16
【问题描述】:

我想为我的应用设置应用链接,但只是让它在某些路径上处于活动状态。换句话说,在我的清单中:

<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>

我不希望有我的域的 每个 url 打开应用程序 - 它们可以像往常一样在浏览器中打开。我只希望包含在应用程序中打开的特定子路径的 url。这种模式是允许的,还是应用链接的“全部或全部”?

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

【问题讨论】:

    标签: android uri url-scheme applinks digital-assets-links


    【解决方案1】:

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

    你应该有

    <data android:scheme="https" android:host="www.mydomain.com" />
    

    然后您可以使用 android:path android:pathPattern 或 android:pathPrefix 创建特殊模式。

    例如,

    <data android:scheme="https" android:host="www.google.com" android:path="/en/index.html"/>
    

    只会捕获网址“https://www.google.com/en/index.html

    【讨论】:

      猜你喜欢
      • 2012-12-12
      • 2020-12-30
      • 1970-01-01
      • 1970-01-01
      • 2012-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多