Don't fire resume upon init - only when returning from background.

Lifecycle behavior for PhoneGap app:
window.onload = loading html page
pause = html page entering background (not displayed)
resume = html page entering foreground (displayed)
window.onunload = leaving html page
This commit is contained in:
Bryce Curtis 2011-11-03 14:22:29 -05:00 committed by Joe Bowser
parent 7244a5a727
commit 141b8355ac
3 changed files with 2 additions and 22 deletions

View File

@ -284,18 +284,6 @@ PhoneGap.onPhoneGapInfoReady = new PhoneGap.Channel('onPhoneGapInfoReady');
*/
PhoneGap.onPhoneGapConnectionReady = new PhoneGap.Channel('onPhoneGapConnectionReady');
/**
* onResume channel is fired when the PhoneGap native code
* resumes.
*/
PhoneGap.onResume = new PhoneGap.Channel('onResume');
/**
* onPause channel is fired when the PhoneGap native code
* pauses.
*/
PhoneGap.onPause = new PhoneGap.Channel('onPause');
/**
* onDestroy channel is fired when the PhoneGap native code
* is destroyed. It is used internally.
@ -435,13 +423,6 @@ document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (e === 'deviceready') {
PhoneGap.onDeviceReady.subscribeOnce(handler);
} else if (e === 'resume') {
PhoneGap.onResume.subscribe(handler);
if (PhoneGap.onDeviceReady.fired) {
PhoneGap.onResume.fire();
}
} else if (e === 'pause') {
PhoneGap.onPause.subscribe(handler);
}
else {
// If subscribing to Android backbutton

View File

@ -730,7 +730,7 @@ public class DroidGap extends PhonegapActivity {
}
// Send pause event to JavaScript
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};");
this.appView.loadUrl("javascript:try{PhoneGap.fireDocumentEvent('pause');}catch(e){};");
// Forward to plugins
this.pluginManager.onPause(this.keepRunning);
@ -771,7 +771,7 @@ public class DroidGap extends PhonegapActivity {
}
// Send resume event to JavaScript
this.appView.loadUrl("javascript:try{PhoneGap.onResume.fire();}catch(e){};");
this.appView.loadUrl("javascript:try{PhoneGap.fireDocumentEvent('resume');}catch(e){};");
// Forward to plugins
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);

View File

@ -239,7 +239,6 @@ public final class PluginManager {
this.plugins.put(className, plugin);
plugin.setContext(this.ctx);
plugin.setView(this.app);
plugin.onResume(true);
return plugin;
}
} catch (Exception e) {