manski's blog

Creating an Application class in Mono for Android

Android provides an Application class.

Base class for those who need to maintain global application state.

Here’s how to create such a class in Mono for Android:

[Application]  // <-- Attribute required
class MyApp : Application {
  // Required constructor
  public MyApp(IntPtr javaReference, JniHandleOwnership transfer) 
    : base(javaReference, transfer) { }

  // Test method - not required
  public override void OnCreate() {
    base.OnCreate();
  }
}

Note: There can only be one such class in an Android application.

One comment

  1. Dinesh said:

    Thanks very much it had helped me alot

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.