diff --git a/library/leakcanary-sample/src/main/java/com/example/leakcanary/ExampleApplication.java b/library/leakcanary-sample/src/main/java/com/example/leakcanary/ExampleApplication.java index 220e05ec06..419b3e2f9f 100644 --- a/library/leakcanary-sample/src/main/java/com/example/leakcanary/ExampleApplication.java +++ b/library/leakcanary-sample/src/main/java/com/example/leakcanary/ExampleApplication.java @@ -17,6 +17,7 @@ import android.app.Application; import android.content.Context; +import android.os.StrictMode; import com.squareup.leakcanary.LeakCanary; import com.squareup.leakcanary.RefWatcher; @@ -32,5 +33,19 @@ public static RefWatcher getRefWatcher(Context context) { @Override public void onCreate() { super.onCreate(); refWatcher = LeakCanary.install(this); + enabledStrictMode(); + } + + private void enabledStrictMode() { + StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() // + .detectAll() // + .penaltyLog() // + .penaltyDeath() // + .build()); + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() // + .detectAll() // + .penaltyLog() // + .penaltyDeath() // + .build()); } }