使用适用于Android的Xamarin Mono中的intent过滤器处理特定URL

Alf*_*and 8 android intentfilter android-manifest xamarin.android xamarin

我试图让我的活动处理的URL采取的形式mydomain.comwww.mydomain.com与两者httphttps方案.目前,我的活动的IntentFilter属性如下所示:

[IntentFilter(
  new[] { Intent.ActionView },
  Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
  DataHost = "mydomain.com",
  DataScheme = "http"
)]
Run Code Online (Sandbox Code Playgroud)

这在清单中生成了这个,并且似乎不适用于任何所需的url配置:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:host="mydomain.com" android:scheme="http" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

如何更改此属性,以便我的活动将处理http(s)://(www.)mydomain.com形式的所有网址?

小智 5

压缩后的单个IntentFilter:

[
    IntentFilter
    (
        new[] { Intent.ActionView },
        Categories = new[]
            {
                Intent.CategoryDefault,
                Intent.CategoryBrowsable
            },
        DataSchemes = new[] { "http", "https" },
        DataHosts = new[] { "*.xamarin.com", "xamarin.com" },
        DataMimeType = "text/plain"
    )
]
Run Code Online (Sandbox Code Playgroud)

将生成以下AndroidManifest.xml节点:

  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:mimeType="text/plain" />
    <data android:host="*.xamarin.com" />
    <data android:host="xamarin.com" />
    <data android:scheme="http" />
    <data android:scheme="https" />
  </intent-filter>
Run Code Online (Sandbox Code Playgroud)