From 4676bfcae89ed5f66ef80de688840a83b37707ba Mon Sep 17 00:00:00 2001 From: Richard Windley Date: Sat, 10 Mar 2018 18:12:57 +0000 Subject: [PATCH] Attempt to fix intermittent crash --- README.MD | 3 +++ package.json | 2 +- plugin.xml | 2 +- .../plugin/fragment/CordovaFragment.java | 20 ++++++++++--------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.MD b/README.MD index b393885..1156b8f 100644 --- a/README.MD +++ b/README.MD @@ -21,6 +21,9 @@ AndroidManifest.xml is automatically updated to use the new MainActivity. Based on cordova-android-fragments (https://github.com/rajivnarayana/CordovaFragments) # History +## 0.0.5 +- Attempt to avoid crash only seen on Galaxy J1 Ace (5.1.1) + ## 0.0.4 - Experimental support for cordova-android 7 - Increased dependency versions diff --git a/package.json b/package.json index 5b558ea..5b9f386 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-android-fragmentactivity", - "version": "0.0.4", + "version": "0.0.5", "description": "An android plugin that provides a replacement activity to the default activity to start a cordova application with MainActivity as a Fragment Activity. Useful when you want to add native views on top of cordova webview.", "cordova": { "id": "cordova-plugin-android-fragmentactivity", diff --git a/plugin.xml b/plugin.xml index 8634a56..3203dd3 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + Cordova Android FragmentActivity Plugin An android plugin that provides a replacement activity to the default activity to start a cordova application with MainActivity as a Fragment Activity. Useful when you want to add native views on top of cordova webview. diff --git a/src/android/uk/co/reallysmall/cordova/plugin/fragment/CordovaFragment.java b/src/android/uk/co/reallysmall/cordova/plugin/fragment/CordovaFragment.java index 53b8d48..9ee4aad 100644 --- a/src/android/uk/co/reallysmall/cordova/plugin/fragment/CordovaFragment.java +++ b/src/android/uk/co/reallysmall/cordova/plugin/fragment/CordovaFragment.java @@ -317,15 +317,17 @@ public void onStart() { /** * The final call you receive before your activity is destroyed. */ - @Override - public void onDestroy() { - LOG.d(TAG, "CordovaActivity.onDestroy()"); - super.onDestroy(); - - if (this.appView != null) { - appView.handleDestroy(); - } - } + @Override + public void onDestroy() { + LOG.d(TAG, "CordovaActivity.onDestroy()"); + if (getActivity() != null) { + super.onDestroy(); + } + + if (this.appView != null) { + appView.handleDestroy(); + } + } @Override public void startActivityForResult(Intent intent, int requestCode) {