summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-01-21 18:01:26 +0100
committerFup Duck <fupduck@sacknagel.com>2018-01-21 18:01:26 +0100
commit6e45a5bcb4de152543b5dd5d9bd2027fb62f7375 (patch)
tree426b1e4ffe9578c106884ce6aef01d9dfa1ca56e /app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
parent3b6bc548f6197dfbd8a4e55524a3f6e0cdd224c0 (diff)
parentdf8b1fcf1ecc55f15229935294a337c897960ff4 (diff)
Merge remote-tracking branch '0xacab/0.9.8' into 8819_config_wizard_design
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
index 88a01b62..f9e45b79 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
@@ -1,6 +1,10 @@
package se.leap.bitmaskclient;
import android.app.Application;
+import android.content.Context;
+
+import com.squareup.leakcanary.LeakCanary;
+import com.squareup.leakcanary.RefWatcher;
/**
* Created by cyberta on 24.10.17.
@@ -8,11 +12,31 @@ import android.app.Application;
public class BitmaskApp extends Application {
+ private RefWatcher refWatcher;
+
@Override
public void onCreate() {
super.onCreate();
+ if (LeakCanary.isInAnalyzerProcess(this)) {
+ // This process is dedicated to LeakCanary for heap analysis.
+ // You should not init your app in this process.
+ return;
+ }
+ refWatcher = LeakCanary.install(this);
+ // Normal app init code...*/
PRNGFixes.apply();
- //TODO: add LeakCanary!
}
+ /**
+ * Use this method to get a RefWatcher object that checks for memory leaks in the given context.
+ * Call refWatcher.watch(this) to check if all references get garbage collected.
+ * @param context
+ * @return the RefWatcher object
+ */
+ public static RefWatcher getRefWatcher(Context context) {
+ BitmaskApp application = (BitmaskApp) context.getApplicationContext();
+ return application.refWatcher;
+ }
+
+
}