Custom Application child class in Mono for Android

android, c#, xamarin.android

Solution

You need to add this constructor to your class in order to make it work:

public AcraApp (IntPtr javaReference, JniHandleOwnership transfer)
    : base(javaReference, transfer)
{
}

Problem

I'm trying to create a child class of "Android.App.Application" to override "OnCreate()", but I can't get it working. Here's my code: ``` namespace MonoAndroidAcra { [Application(Debuggable=true, Label="insert label here", ManageSpaceActivity = typeof(MainActivity))] class AcraApp : Application { public override void OnCreate() { base.OnCreate(); } } } ``` `MainActivity` is just the default example activity. Now, when I debug the project I get a `System.NotSupportedException`: Unable to activate instance of type MonoAndroidAcra.AcraApp from native handle 405191a0 No call stack is available for this exception. How do I do this correctly? I couldn't find any examples for this. I'm using the latest stable version of Mono for Android.

Original source

Related problems