Skip to content

Instantly share code, notes, and snippets.

@heytherewill
Created August 15, 2019 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heytherewill/27b1e67c844277df5b25e6e4e18459ce to your computer and use it in GitHub Desktop.
Save heytherewill/27b1e67c844277df5b25e6e4e18459ce to your computer and use it in GitHub Desktop.
using Android.App;
using Android.OS;
using Android.Support.Design.Widget;
using Android.Support.V7.App;
namespace LeakTest
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
StrictMode.SetVmPolicy(
new StrictMode.VmPolicy.Builder()
.DetectActivityLeaks()
.DetectLeakedClosableObjects()
.DetectLeakedRegistrationObjects()
.DetectLeakedSqlLiteObjects()
.PenaltyLog()
.Build());
StrictMode.SetThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.DetectCustomSlowCalls()
.PenaltyLog()
.Build());
FindViewById<FloatingActionButton>(Resource.Id.fab).Click += delegate
{
StartActivity(typeof(LeakingActivity));
};
}
}
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar")]
public class LeakingActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment