0

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

Libin Joseph
  • 7,070
  • 5
  • 29
  • 52

2 Answers2

4

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.

Community
  • 1
  • 1
Akash Amin
  • 2,741
  • 19
  • 38
1

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>
Vickyexpert
  • 3,147
  • 5
  • 21
  • 34
  • With xamarin, the manifest file is auto generated right? And its in the obj folder. I dont know if overriding the code will work – Libin Joseph May 31 '16 at 05:35
  • It should work, I don't have idea for this, but I have edited manifest file in phonegap and done some changes as requirement then also app runs properly so you can check it, and don't forget to keep backup first so you can revoke if not work for you... – Vickyexpert May 31 '16 at 05:43