I'm attempting to have my Activity handle urls taking the form of mydomain.com
or www.mydomain.com
with both http
and https
schemes. Currently the IntentFilter attribute for my activity looks like this:
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataHost = "mydomain.com",
DataScheme = "http"
)]
Which generates this in the manifest, and doesn't appear to be working for any of the required url configurations:
<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>
How can I change this attribute so that my activity will handle all urls of the form http(s)://(www.)mydomain.com ?
Android Intent Filters with Examples In android, Intent Filter is an expression in the app’s manifest file (ActivityMainfest.xml) and it is used to specify the type of intents that the component would like to receive.
Intent Services in Xamarin.Android. Intent Services Overview. Both started and bound services run on the main thread, which means that to keep performance smooth, a service needs to perform the work asynchronously.
If multiple intent filters are compatible, the system displays a dialog so the user can pick which app to use. An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive.
This guide requires Xamarin.Android 6.1 and an application that targets Android 6.0 (API level 23) or higher. App-linking is possible in earlier versions of Android by using the Rivets NuGet package from the Xamarin Component store. The Rivets package is not compatible with app-linking in Android 6.0; it does not support Android 6.0 app linking.
Compressed single IntentFilter:
[
IntentFilter
(
new[] { Intent.ActionView },
Categories = new[]
{
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataSchemes = new[] { "http", "https" },
DataHosts = new[] { "*.xamarin.com", "xamarin.com" },
DataMimeType = "text/plain"
)
]
will generate following AndroidManifest.xml node:
<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>
You can add multiple intent filter attributes
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataHost = "mydomain.com",
DataScheme = "http"
)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataHost = "mydomain.com",
DataScheme = "https"
)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataHost = "*.mydomain.com",
DataScheme = "http"
)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataHost = "*.mydomain.com",
DataScheme = "https"
)]
public class MyActivity : Activity {}
the resulting xml will be
<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>
<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="https" />
</intent-filter>
<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>
<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="https" />
</intent-filter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With