Reputation: 7352
I would like to open up my xamarin android app, from a web link. I have added the following intent code in my Activity class:
[IntentFilter(new []{ Intent.ActionView },
Categories = new []
{
Android.Content.Intent.CategoryDefault,
Android.Content.Intent.CategoryBrowsable
},
DataScheme = "https",
DataHost = "CinCardReader.Droid")]
and the HTML file to open up the app is :
<html>
<title>Open Android Application</title>
<head>
</head>
<body>
<a href="intent://CinCardReader.Droid/#Intent;scheme=launch;package=CinCardReader.Droid;S.content=WebContent;end">Open Application</a><br>
</html>
I appreciate if someone can help me fix the error. Right now, when i click on the link it gives an error: net::ERR_UNKNOWN_URL_SCHEME
Upvotes: 0
Views: 2421
Reputation: 2761
Edit your manifest file manually, you will find the file in Properties folder in your solution folder. Add the below code
<activity android:name="MainActivity">
<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:scheme="my_scheme" android:host="my_host" />
</intent-filter>
</activity>
You url in the browser will be :
<a href="intent://my_host/#Intent;scheme=my_scheme;end">Open Application</a><br>
You don't need package name if you have a unique scheme. The link will search for the scheme and open the application. I have tried this and it is working in Xamarin.
If you want a custom Action to be opened then this link will help you.
Upvotes: 4
Reputation: 3167
Try to code like below in your manifest file for that, then you will be able to manage the URL and open app from browser.
<activity android:name=”MainActivity”>
<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.your_domain.com" />
<data android:scheme="https" android:host="www.your_domain.com" />
</intent-filter>
</activity>
Upvotes: 1