Search code examples
androidxamarinxamarin.androidxamarin-android-player

Empty Chooser with ActionSend Intent in Android


I'm using Xamarin to create a simple Android application. I want to display a ListView to the user and when an item is clicked a Chooser is displayed to send some text to another application (e.g. SMS, email). I've got the ListView working, but when an item is clicked the Chooser that is displayed doesn't have any options; it just shows the Chooser header. I'm using the Xamarin Android Player, and I've tried with different versions of Android. Any idea what the problem is?

        this.ListView.ItemClick += (sender, e) =>
        {
            var sendIntent = new Intent();
            sendIntent.SetAction(Intent.ActionSend);
            sendIntent.PutExtra(Intent.ExtraText, "This is my text to send.");
            sendIntent.SetType("text/plain");
            StartActivity(Intent.CreateChooser(sendIntent, "Share With..."));
        };

enter image description here


Solution

  • Your code is fine. It is the Android Emulator that is the problem since you do not appear to have Send-enabled Apps installed, thus the empty list.

    i.e. On a GenyMotion emulator with GApps installed, your code produces:

    enter image description here

    Either:

    1) Test on a physical device that has one or more "send enabled" apps installed

    Or:

    2) Install Google Play on your Xamarin's emulator instance and install some apps