This commit is contained in:
Sebastián Katzer 2014-11-17 14:19:29 +01:00
parent a60716620a
commit 8280fdeb3a
4 changed files with 16 additions and 21 deletions

View File

@ -81,14 +81,9 @@ public class BackgroundMode extends CordovaPlugin {
public boolean execute (String action, JSONArray args,
CallbackContext callback) throws JSONException {
if (action.equalsIgnoreCase("observeLifeCycle")) {
// Nothing to do here
return true;
}
if (action.equalsIgnoreCase("configure")) {
setSettings(args.getJSONObject(0));
updateNotifcation();
return true;
}
@ -160,15 +155,20 @@ public class BackgroundMode extends CordovaPlugin {
}
/**
* Update the settings and maybe the notification.
* Update the settings for the notification.
*
* @param newSettings
* The new settings
*/
private void setSettings(JSONObject newSettings) {
settings = newSettings;
}
if (inBackground) {
/**
* Update the notification.
*/
private void updateNotifcation() {
if (isBind) {
stopService();
startService();
}

View File

@ -34,12 +34,13 @@
[self disable:NULL];
[self configureAudioPlayer];
[self configureAudioSession];
[self observeLifeCycle];
}
/**
* Register the listener for pause and resume events.
*/
- (void) observeLifeCycle:(CDVInvokedUrlCommand *)command
- (void) observeLifeCycle
{
NSNotificationCenter* listener = [NSNotificationCenter defaultCenter];

View File

@ -84,15 +84,6 @@ namespace Cordova.Extension.Commands
Deactivate();
}
/// </summary>
/// @js-interface
/// Registriert die Listener für die (sleep/resume) Events
/// </summary>
public void observeLifeCycle (string args)
{
// Konstruktor wird aufgerufen, falls Instanz erstellt wurde
}
/// </summary>
/// Startet das Aktualisieren des Standpunktes
/// </summary>

View File

@ -19,7 +19,7 @@
under the License.
*/
var exec = require('cordova/exec'),
var exec = require('cordova/exec'),
channel = require('cordova/channel');
@ -27,10 +27,13 @@ var exec = require('cordova/exec'),
document.addEventListener('backbutton', function () {}, false);
channel.deviceready.subscribe(function () {
// Registriert die Listener für die (sleep/resume) Events
cordova.exec(null, null, 'BackgroundMode', 'observeLifeCycle', []);
// Set the default settings
exports.configure();
// Only enable WP8 by default
if (['WinCE', 'Win32NT'].indexOf(device.platform)) {
exports.enable();
}
});