diff --git a/sdk/android/src/main/java/com/raygun/react/RaygunNativeBridgeModule.java b/sdk/android/src/main/java/com/raygun/react/RaygunNativeBridgeModule.java index 2f24676..473d0bf 100644 --- a/sdk/android/src/main/java/com/raygun/react/RaygunNativeBridgeModule.java +++ b/sdk/android/src/main/java/com/raygun/react/RaygunNativeBridgeModule.java @@ -126,12 +126,12 @@ public void initRealUserMonitoringNativeSupport() { //Cant initialise bridge rum twice if (realUserMonitoringInitialized) return; - if (reactContext.getCurrentActivity() != null) { + if (reactContext != null && reactContext.getCurrentActivity() != null) { //Store the current activity to differentiate session changes currentActivity = new WeakReference<>(reactContext.getCurrentActivity()); //Attach the activity listening logic to the Application reactContext.getCurrentActivity().getApplication().registerActivityLifecycleCallbacks(this); - } else Log.e("TAG", "This react application has no active activity"); + } else Log.e("Raygun", "This react application has no active activity"); realUserMonitoringInitialized = true; } @@ -186,16 +186,21 @@ public void onActivityStarted(Activity activity) { public void onActivityResumed(Activity activity) { //If the activity that recently paused is returning to the foreground then the whole // application has resumed, therefore update the session - if (currentActivity.get() == activity) this.sendJSEvent(ON_SESSION_RESUME, null); - + if (currentActivity != null && currentActivity.get() == activity) { + this.sendJSEvent(ON_SESSION_RESUME, null); + } + else { //If any other activity resumes that means that it is taking over from the current activity - else currentActivity = new WeakReference<>(activity); + currentActivity = new WeakReference<>(activity); + } } @Override public void onActivityPaused(Activity activity) { //If the current activity is pausing then the session is paused - if (currentActivity.get() == activity) this.sendJSEvent(ON_SESSION_PAUSE, null); + if (currentActivity != null && currentActivity.get() == activity) { + this.sendJSEvent(ON_SESSION_PAUSE, null); + } } @Override @@ -208,7 +213,7 @@ public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { @Override public void onActivityDestroyed(Activity activity) { - if (currentActivity.get() == activity) { + if (currentActivity != null && currentActivity.get() == activity) { this.sendJSEvent(ON_SESSION_END, null); currentActivity = null; } diff --git a/sdk/package.json b/sdk/package.json index 585951b..34dfc49 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,7 +1,7 @@ { "name": "raygun4reactnative", "title": "Raygun4reactnative", - "version": "1.1.4", + "version": "1.1.5", "description": "Raygun React Native SDK", "main": "dist/index.js", "typescript": {