I use xamarin to write a very simple app. to start a very simple activity. but, when I use leakCanady, it reports a leak. the mainActivity is as follows.
namespace SampleApp { [Activity(Label = "SampleApp", MainLauncher = true)] public class MainActivity : Activity { private Button _button;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.main);
_button = FindViewById<Button>(Resource.Id.button);
_button.Click += OnButtonClicked;
}
protected override void OnDestroy()
{
_button.Click -= OnButtonClicked;
_button.Dispose();
base.OnDestroy();
Dispose();
}
private void OnButtonClicked(object sender, EventArgs e)
{
StartActivity(typeof(LeakingActivity));
}
}
and the new activity is as follows public class LeakingActivity : AppCompatActivity { //private TextView _textView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.layout1);
//_textView = FindViewById<TextView>(Resource.Id.textView);
}
protected override void OnDestroy()
{
// Dispose all disposable members
//_textView.Dispose();
base.OnDestroy();
}
}
}
Please help me to solve it. thanks