Add onMessage(id, data) to plugin API.

A solution was needed to notify the audio player to pause when a phone call comes in. The option was to add a specific onPhone() method or generalize it. Since there are other "events" that are useful to plugins, a generalized solution was used. It is also extensible without changing the plugin API again.

Any plugin can call DroidGap.onMessage() to send a message/event to all other plugins. NetworkManager was updated to send changes in connection status to plugins, so they can intelligently handle lost connections.
This commit is contained in:
Bryce Curtis
2011-11-09 10:34:49 -06:00
parent fd93404c7c
commit 0bbcf5cfd2
10 changed files with 174 additions and 8 deletions
+12
View File
@@ -814,6 +814,18 @@ public class DroidGap extends PhonegapActivity {
}
}
/**
* Send a message to all plugins.
*
* @param id The message id
* @param data The message data
*/
public void onMessage(String id, Object data) {
// Forward to plugins
this.pluginManager.onMessage(id, data);
}
/**
* Add a class that implements a service.
*