I want to link to my app from an e-mail. The Xamarin documentations describes how to link to an app:
http://developer.xamarin.com/recipes/cross-platform/app-links/app-links-android/
However, it does that by referring to an additional component (Rivets) and it focuses on linking by code:
Rivets.AppLinks.Navigator.Navigate("http://location/of/your/html/file.html");
and it requires to publish a page:
Publish this page somewhere on the internet, or at a location your Android app can reach.
This feels like a complex solution for a very simple problem. I want to link from an e-mail to my app in a way that just works, even if my website would not work and preferably without additional components. I tried to do that based on explanations that focus on Android Java applications. This https://stackoverflow.com/a/11526028 and this https://stackoverflow.com/a/2958870
I did not succeed for my Xamarin app. Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AndroidLink.AndroidLink" android:versionCode="1" android:versionName="1.0">
<uses-sdk />
<application android:label="AndroidLink" android:icon="@drawable/Icon">
<activity android:name=".MainActivity" android:exported="false">
<intent-filter>
<data android:scheme="http" android:host="twitter.com" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
</manifest>
When I send myself an e-mail with the following content http://twitter.com/status/1234
and click on that link in the Gmail app, the browser is opened, instead of my App.
Hopefully, this problem is solvable with Xamarin Android. Please note that:
- I want to link from an e-mail to my app.
- I prefer a working solution, even if my website would be down.
- I prefer the browser not to be opened.
In case, it is relevant, here is my C# code:
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
var data = Intent.Data;
if (data != null)
{
var scheme = data.Scheme;
var host = data.Host;
var pathSegments = data.PathSegments;
button.Text = pathSegments.Count.ToString();
}
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
}