public static RefWatcher install(Application application) { if (BuildConfig.DEBUG) { ExcludedRefs excludedRefs = AndroidExcludedRefs.createAppDefaults() //exclude InputMethodManager .clazz("android.view.inputmethod.InputMethodManager") .build(); return LeakCanary.refWatcher(application) .listenerServiceClass(DisplayLeakService.class) .excludedRefs(excludedRefs) .buildAndInstall(); } else { return LeakCanary.install(application); } }
@TargetApi(value = android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static RefWatcher install(Application application, boolean debug) { RefWatcher watcher = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (debug) { watcher = LeakCanary.install(application, DisplayLeakService.class); } else { watcher = ReleaseLeakCanary.install(application); } } return watcher; }