Skip to content

Commit

Permalink
Don't fire resume upon init - only when returning from background.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brycecurtis authored and Joe Bowser committed Nov 4, 2011
1 parent 7244a5a commit 141b835
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
19 changes: 0 additions & 19 deletions framework/assets/js/phonegap.js.base
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions framework/src/com/phonegap/DroidGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ protected void onPause() {
}

// 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);
Expand Down Expand Up @@ -771,7 +771,7 @@ protected void onResume() {
}

// 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);
Expand Down
1 change: 0 additions & 1 deletion framework/src/com/phonegap/api/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ private IPlugin addPlugin(String pluginName, String className) {
this.plugins.put(className, plugin);
plugin.setContext(this.ctx);
plugin.setView(this.app);
plugin.onResume(true);
return plugin;
}
} catch (Exception e) {
Expand Down

0 comments on commit 141b835

Please sign in to comment.