Skip to content

Commit

Permalink
Pass the java handle down to the base constructor to avoid a potentia…
Browse files Browse the repository at this point in the history
…lly nasty leak

I haven't seen this in the wild but it should prevent a disconnect between the java and c#
if instantiating the activity from java. I don't *think* we'd hit this unless starting an activity
from an intent on the java side of things and we happened to override a virtual method called
from one of the constructors.

See http://developer.xamarin.com/guides/android/under_the_hood/architecture/#Java_Activation
  • Loading branch information
kjeremy committed Jul 17, 2015
1 parent 1e563c3 commit aa8027f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cirrious/Cirrious.MvvmCross.Droid/Views/MvxActivity.cs
Expand Up @@ -22,6 +22,7 @@ public abstract class MvxActivity
{

protected MvxActivity(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
BindingContext = new MvxAndroidBindingContext(this, this);
this.AddEventListeners();
Expand Down
Expand Up @@ -24,7 +24,8 @@ protected MvxEventSourceActivity()

}

protected MvxEventSourceActivity(IntPtr javaReference, JniHandleOwnership transfer) { }
protected MvxEventSourceActivity(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer) { }

protected override void OnCreate(Bundle bundle)
{
Expand Down

0 comments on commit aa8027f

Please sign in to comment.