Always call plugin's onPause/onResume with multitasking flag when these lifecycle events occur in activity. It is up to the plugin to handle as necessary.

This commit is contained in:
Bryce Curtis 2011-06-23 23:22:48 -05:00 committed by Joe Bowser
parent 435c903baf
commit 05eacf4792
4 changed files with 22 additions and 10 deletions

View File

@ -628,7 +628,7 @@ public class DroidGap extends PhonegapActivity {
this.appView.loadUrl("javascript:try{PhoneGap.onPause.fire();}catch(e){};");
// Forward to plugins
this.pluginManager.onPause();
this.pluginManager.onPause(this.keepRunning);
// If app doesn't want to run in background
if (!this.keepRunning) {
@ -663,7 +663,7 @@ public class DroidGap extends PhonegapActivity {
this.appView.loadUrl("javascript:try{PhoneGap.onResume.fire();}catch(e){};");
// Forward to plugins
this.pluginManager.onResume();
this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
// If app doesn't want to run in background
if (!this.keepRunning || this.activityResultKeepRunning) {

View File

@ -54,13 +54,17 @@ public interface IPlugin {
/**
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
void onPause();
void onPause(boolean multitasking);
/**
* Called when the activity will start interacting with the user.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
void onResume();
void onResume(boolean multitasking);
/**
* The final call you receive before your activity is destroyed.

View File

@ -64,14 +64,18 @@ public abstract class Plugin implements IPlugin {
/**
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
public void onPause() {
public void onPause(boolean multitasking) {
}
/**
* Called when the activity will start interacting with the user.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
public void onResume() {
public void onResume(boolean multitasking) {
}
/**

View File

@ -230,27 +230,31 @@ public final class PluginManager {
/**
* Called when the system is about to start resuming a previous activity.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
public void onPause() {
public void onPause(boolean multitasking) {
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
while(it.hasNext()) {
Entry<String,Plugin> entry = it.next();
Plugin plugin = entry.getValue();
plugin.onPause();
plugin.onPause(multitasking);
}
}
/**
* Called when the activity will start interacting with the user.
*
* @param multitasking Flag indicating if multitasking is turned on for app
*/
public void onResume() {
public void onResume(boolean multitasking) {
java.util.Set<Entry<String,Plugin>> s = this.plugins.entrySet();
java.util.Iterator<Entry<String,Plugin>> it = s.iterator();
while(it.hasNext()) {
Entry<String,Plugin> entry = it.next();
Plugin plugin = entry.getValue();
plugin.onResume();
plugin.onResume(multitasking);
}
}