From 40781fe813b64e466e9bbaed0fc672c5d6fc34e9 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Tue, 18 Oct 2016 14:10:19 +0200 Subject: [PATCH] Fix Application Context --- .../reactlibrary/RNInstabugReactnativeModule.java | 8 ++++---- .../reactlibrary/RNInstabugReactnativePackage.java | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 4815a06..60e9ecc 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -22,11 +22,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { private Instabug mInstabug; private String mAndroidApplicationToken; private Instabug.Builder mBuilder; - private Application mApplication; + private Application androidApplication; - public RNInstabugReactnativeModule(ReactApplicationContext reactContext) { + public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Application androidApplication) { super(reactContext); - this.mApplication = reactContext.getApplicationContext(); + this.androidApplication = androidApplication } @Override @@ -44,7 +44,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { { this.mAndroidApplicationToken = androidApplicationToken; - mInstagbug = new Instabug.Builder(mApplication, mAndroidApplicationToken) + mInstagbug = new Instabug.Builder(androidApplication, mAndroidApplicationToken) .setDebugEnabled(true) .setEmailFieldRequired(false) .setFloatingButtonOffsetFromTop(400) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java index 8319ca3..68d8421 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java @@ -16,10 +16,16 @@ import com.facebook.react.bridge.JavaScriptModule; public class RNInstabugReactnativePackage implements ReactPackage { + Application androidApplication; + + public RNInstabugReactnativePackage(Application application) { + this.androidApplication = application; + } + @Override public List createNativeModules(ReactApplicationContext reactContext) { List modules = new ArrayList<>(); - modules.add(new RNInstabugReactnativeModule(reactContext)); + modules.add(new RNInstabugReactnativeModule(reactContext,androidApplication)); return modules; }