diff --git a/framework/src/org/apache/cordova/AndroidWebView.java b/framework/src/org/apache/cordova/AndroidWebView.java index 68808c61..1e8cccc7 100755 --- a/framework/src/org/apache/cordova/AndroidWebView.java +++ b/framework/src/org/apache/cordova/AndroidWebView.java @@ -594,6 +594,7 @@ public class AndroidWebView extends WebView implements CordovaWebView { return boundKeyCodes.contains(keyCode); } + @Override public void handlePause(boolean keepRunning) { LOG.d(TAG, "Handle the pause"); @@ -607,22 +608,23 @@ public class AndroidWebView extends WebView implements CordovaWebView { // If app doesn't want to run in background if (!keepRunning) { - // Pause JavaScript timers (including setInterval) + // Pause JavaScript timers. This affects all webviews within the app! this.pauseTimers(); } } - public void handleResume(boolean keepRunning, boolean activityResultKeepRunning) + @Override + public void handleResume(boolean keepRunning) { + // Resume JavaScript timers. This affects all webviews within the app! + this.resumeTimers(); + sendJavascriptEvent("resume"); // Forward to plugins if (this.pluginManager != null) { this.pluginManager.onResume(keepRunning); } - - // Resume JavaScript timers (including setInterval) - this.resumeTimers(); } public void handleDestroy() diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 30370c22..0afd5713 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -96,7 +96,6 @@ public class CordovaActivity extends Activity implements CordovaInterface { // Plugin to call when activity result is received protected int activityResultRequestCode; protected CordovaPlugin activityResultCallback; - protected boolean activityResultKeepRunning; /* * The variables below are used to cache some of the activity properties. @@ -281,19 +280,14 @@ public class CordovaActivity extends Activity implements CordovaInterface { @Override protected void onPause() { super.onPause(); - - LOG.d(TAG, "Paused the application!"); + LOG.d(TAG, "Paused the activity."); // Don't process pause if shutting down, since onDestroy() will be called if (this.activityState == ACTIVITY_EXITING) { return; } - if (this.appView == null) { - return; - } - else - { + if (this.appView != null) { this.appView.handlePause(this.keepRunning); } } @@ -315,7 +309,7 @@ public class CordovaActivity extends Activity implements CordovaInterface { @Override protected void onResume() { super.onResume(); - LOG.d(TAG, "Resuming the App"); + LOG.d(TAG, "Resumed the activity."); if (this.activityState == ACTIVITY_STARTING) { this.activityState = ACTIVITY_RUNNING; @@ -329,17 +323,7 @@ public class CordovaActivity extends Activity implements CordovaInterface { // receive user input. Workaround for some devices (Samsung Galaxy Note 3 at least) this.getWindow().getDecorView().requestFocus(); - this.appView.handleResume(this.keepRunning, this.activityResultKeepRunning); - - // If app doesn't want to run in background - if (!this.keepRunning || this.activityResultKeepRunning) { - - // Restore multitasking state - if (this.activityResultKeepRunning) { - this.keepRunning = this.activityResultKeepRunning; - this.activityResultKeepRunning = false; - } - } + this.appView.handleResume(this.keepRunning); } /** @@ -382,13 +366,6 @@ public class CordovaActivity extends Activity implements CordovaInterface { */ public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) { setActivityResultCallback(command); - this.activityResultKeepRunning = this.keepRunning; - - // If multitasking turned on, then disable it for activities that return results - if (command != null) { - this.keepRunning = false; - } - try { startActivityForResult(intent, requestCode); } catch (RuntimeException e) { // E.g.: ActivityNotFoundException diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 8fd259c7..184467b3 100644 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -34,7 +34,7 @@ public interface CordovaWebView { void onNewIntent(Intent intent); - void handleResume(boolean keepRunning, boolean activityResultKeepRunning); + void handleResume(boolean keepRunning); void handleDestroy();