mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 00:11:03 +08:00
CB-7947 Don't force-pauseTimers() for startActivityForResult
This commit is contained in:
parent
3b909253bb
commit
b59705bed4
@ -594,6 +594,7 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
|||||||
return boundKeyCodes.contains(keyCode);
|
return boundKeyCodes.contains(keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handlePause(boolean keepRunning)
|
public void handlePause(boolean keepRunning)
|
||||||
{
|
{
|
||||||
LOG.d(TAG, "Handle the pause");
|
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 app doesn't want to run in background
|
||||||
if (!keepRunning) {
|
if (!keepRunning) {
|
||||||
// Pause JavaScript timers (including setInterval)
|
// Pause JavaScript timers. This affects all webviews within the app!
|
||||||
this.pauseTimers();
|
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");
|
sendJavascriptEvent("resume");
|
||||||
|
|
||||||
// Forward to plugins
|
// Forward to plugins
|
||||||
if (this.pluginManager != null) {
|
if (this.pluginManager != null) {
|
||||||
this.pluginManager.onResume(keepRunning);
|
this.pluginManager.onResume(keepRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resume JavaScript timers (including setInterval)
|
|
||||||
this.resumeTimers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDestroy()
|
public void handleDestroy()
|
||||||
|
@ -96,7 +96,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
// Plugin to call when activity result is received
|
// Plugin to call when activity result is received
|
||||||
protected int activityResultRequestCode;
|
protected int activityResultRequestCode;
|
||||||
protected CordovaPlugin activityResultCallback;
|
protected CordovaPlugin activityResultCallback;
|
||||||
protected boolean activityResultKeepRunning;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The variables below are used to cache some of the activity properties.
|
* The variables below are used to cache some of the activity properties.
|
||||||
@ -281,19 +280,14 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
LOG.d(TAG, "Paused the activity.");
|
||||||
LOG.d(TAG, "Paused the application!");
|
|
||||||
|
|
||||||
// Don't process pause if shutting down, since onDestroy() will be called
|
// Don't process pause if shutting down, since onDestroy() will be called
|
||||||
if (this.activityState == ACTIVITY_EXITING) {
|
if (this.activityState == ACTIVITY_EXITING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.appView == null) {
|
if (this.appView != null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.appView.handlePause(this.keepRunning);
|
this.appView.handlePause(this.keepRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +309,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
LOG.d(TAG, "Resuming the App");
|
LOG.d(TAG, "Resumed the activity.");
|
||||||
|
|
||||||
if (this.activityState == ACTIVITY_STARTING) {
|
if (this.activityState == ACTIVITY_STARTING) {
|
||||||
this.activityState = ACTIVITY_RUNNING;
|
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)
|
// receive user input. Workaround for some devices (Samsung Galaxy Note 3 at least)
|
||||||
this.getWindow().getDecorView().requestFocus();
|
this.getWindow().getDecorView().requestFocus();
|
||||||
|
|
||||||
this.appView.handleResume(this.keepRunning, this.activityResultKeepRunning);
|
this.appView.handleResume(this.keepRunning);
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -382,13 +366,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*/
|
*/
|
||||||
public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
|
public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
|
||||||
setActivityResultCallback(command);
|
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 {
|
try {
|
||||||
startActivityForResult(intent, requestCode);
|
startActivityForResult(intent, requestCode);
|
||||||
} catch (RuntimeException e) { // E.g.: ActivityNotFoundException
|
} catch (RuntimeException e) { // E.g.: ActivityNotFoundException
|
||||||
|
@ -34,7 +34,7 @@ public interface CordovaWebView {
|
|||||||
|
|
||||||
void onNewIntent(Intent intent);
|
void onNewIntent(Intent intent);
|
||||||
|
|
||||||
void handleResume(boolean keepRunning, boolean activityResultKeepRunning);
|
void handleResume(boolean keepRunning);
|
||||||
|
|
||||||
void handleDestroy();
|
void handleDestroy();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user