1

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:

  1. I want to link from an e-mail to my app.
  2. I prefer a working solution, even if my website would be down.
  3. 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++); }; } } 
7
  • When you add an Intent filter for URI scheme, Android will let you choose a default app. Are you sure you haven't selected an app for twitter.com? Try using a scheme or domain that is unique. Commented May 31, 2015 at 19:24
  • You also might want to consider using an IntentFilter attribute in your code instead of the manifest file. See androidapi.xamarin.com/…* Commented May 31, 2015 at 19:29
  • Thanks for your reply. I am sure I have not selected an app for twitter.com. The problem is also for other websites. Commented May 31, 2015 at 20:11
  • Same problem when adding IntentFilter in code, also for another website: [IntentFilter(new[] { Intent.ActionView }, DataHost = "geenstijl.nl", DataScheme = "http")] Commented May 31, 2015 at 20:36
  • Just tried: same problem for other schemes. Commented May 31, 2015 at 23:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.