From 088140aca49196dd648bb99360c94f7ee88d7711 Mon Sep 17 00:00:00 2001 From: Carlos Santana Date: Thu, 28 Jan 2016 15:57:38 -0500 Subject: [PATCH] CB-10472 NullPointerException: org.apache.cordova.PluginManager.onSaveInstanceState check if pluginManager is null before using it This closes #255 --- .../apache/cordova/CordovaInterfaceImpl.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 65e2a90d..d1420b6b 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -108,17 +108,20 @@ public class CordovaInterfaceImpl implements CordovaInterface { // If there was no Activity result, we still need to send out the resume event if the // Activity was destroyed by the OS activityWasDestroyed = false; - - CoreAndroid appPlugin = (CoreAndroid) pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME); - if(appPlugin != null) { - JSONObject obj = new JSONObject(); - try { - obj.put("action", "resume"); - } catch (JSONException e) { - LOG.e(TAG, "Failed to create event message", e); + if(pluginManager != null) + { + CoreAndroid appPlugin = (CoreAndroid) pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME); + if(appPlugin != null) { + JSONObject obj = new JSONObject(); + try { + obj.put("action", "resume"); + } catch (JSONException e) { + LOG.e(TAG, "Failed to create event message", e); + } + appPlugin.sendResumeEvent(new PluginResult(PluginResult.Status.OK, obj)); } - appPlugin.sendResumeEvent(new PluginResult(PluginResult.Status.OK, obj)); } + } } @@ -169,8 +172,10 @@ public class CordovaInterfaceImpl implements CordovaInterface { String serviceName = activityResultCallback.getServiceName(); outState.putString("callbackService", serviceName); } + if(pluginManager != null){ + outState.putBundle("plugin", pluginManager.onSaveInstanceState()); + } - outState.putBundle("plugin", pluginManager.onSaveInstanceState()); } /**