Displaying error messages with Android and MonoDroid

One of the most annoying things when I build a desktop app in .NET is MessageBox.Show() for displaying images or using a alert() in Javascript is that I have to click on the popup dialog to make it go away.  I love the little messages at the bottom of an Android screen that come up, display some text, and then go away.  Its a Toast.  Here's a simple call to make one display.

Toast.MakeText(this, "some info goes here", ToastLength.Short).Show(); 

In my case, I wanted to report an error, so I did this:

            catch (System.Exception e)
            {
                // log the error to the android logs.
                Android.Util.Log.D("MEDIA_PLAYER", e.Message);
                Toast.MakeText(this, e.Message, ToastLength.Short).Show();
            }

I hope that this helps you out

No Comments