diff --git a/framework/ext/src/com/phonegap/api/PluginManager.java b/framework/ext/src/com/phonegap/api/PluginManager.java index 4dd2af2..98b505f 100644 --- a/framework/ext/src/com/phonegap/api/PluginManager.java +++ b/framework/ext/src/com/phonegap/api/PluginManager.java @@ -31,17 +31,27 @@ public final class PluginManager extends Scriptable { /** * Field used to invoke Plugin actions. */ - public static final String FIELD_EXEC = "exec"; + public static String FIELD_EXEC = "exec"; /** * Field used to cleanup Plugins. */ - public static final String FIELD_DESTROY = "destroy"; + public static String FIELD_DESTROY = "destroy"; + + /** + * Field used to indicate application has been brought to foreground. + */ + public static String FIELD_RESUME = "resume"; + + /** + * Field used to indicate application has been sent to background + */ + public static String FIELD_PAUSE = "pause"; /** * Field used to register a Plugin. */ - public static final String FIELD_ADD_PLUGIN = "addPlugin"; + public static String FIELD_ADD_PLUGIN = "addPlugin"; /** * Loads the appropriate PhoneGap Plugins and invokes their actions. @@ -103,6 +113,24 @@ public Object invoke(Object obj, Object[] oargs) throws Exception { } }; } + else if (name.equals(FIELD_RESUME)) { + final PluginManagerFunction plugin_mgr = this.pluginManagerFunction; + return new ScriptableFunction() { + public Object invoke(Object obj, Object[] oargs) throws Exception { + plugin_mgr.onResume(); + return null; + } + }; + } + else if (name.equals(FIELD_PAUSE)) { + final PluginManagerFunction plugin_mgr = this.pluginManagerFunction; + return new ScriptableFunction() { + public Object invoke(Object obj, Object[] oargs) throws Exception { + plugin_mgr.onPause(); + return null; + } + }; + } else if (name.equals(FIELD_ADD_PLUGIN)) { final PluginManager plugin_mgr = this; return new ScriptableFunction() { diff --git a/framework/ext/src/com/phonegap/api/PluginManagerFunction.java b/framework/ext/src/com/phonegap/api/PluginManagerFunction.java index 62da825..043b029 100644 --- a/framework/ext/src/com/phonegap/api/PluginManagerFunction.java +++ b/framework/ext/src/com/phonegap/api/PluginManagerFunction.java @@ -195,7 +195,7 @@ public Plugin getPlugin(String className) { } /** - * Called when Plugin is paused. + * Called when application is paused. */ public void onPause() { Enumeration e = this.plugins.elements(); @@ -206,7 +206,7 @@ public void onPause() { } /** - * Called when Plugin is resumed. + * Called when application is resumed. */ public void onResume() { Enumeration e = this.plugins.elements(); @@ -217,7 +217,7 @@ public void onResume() { } /** - * Called when Plugin is destroyed. + * Called when application is destroyed. */ public void onDestroy() { Enumeration e = this.plugins.elements(); diff --git a/javascript/_phonegap.js b/javascript/_phonegap.js index f19830e..2e62ece 100644 --- a/javascript/_phonegap.js +++ b/javascript/_phonegap.js @@ -221,6 +221,9 @@ PhoneGap.onPause = new PhoneGap.Channel('onPause'); */ blackberry.app.event.onForeground(function() { PhoneGap.onResume.fire(); + + // notify PhoneGap JavaScript Extension + phonegap.PluginManager.resume(); }); /** @@ -229,6 +232,9 @@ blackberry.app.event.onForeground(function() { */ blackberry.app.event.onBackground(function() { PhoneGap.onPause.fire(); + + // notify PhoneGap JavaScript Extension + phonegap.PluginManager.pause(); }); /**