Clean up
This commit is contained in:
parent
a60716620a
commit
8280fdeb3a
@ -81,14 +81,9 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
public boolean execute (String action, JSONArray args,
|
public boolean execute (String action, JSONArray args,
|
||||||
CallbackContext callback) throws JSONException {
|
CallbackContext callback) throws JSONException {
|
||||||
|
|
||||||
if (action.equalsIgnoreCase("observeLifeCycle")) {
|
|
||||||
// Nothing to do here
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.equalsIgnoreCase("configure")) {
|
if (action.equalsIgnoreCase("configure")) {
|
||||||
setSettings(args.getJSONObject(0));
|
setSettings(args.getJSONObject(0));
|
||||||
|
updateNotifcation();
|
||||||
return true;
|
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
|
* @param newSettings
|
||||||
* The new settings
|
* The new settings
|
||||||
*/
|
*/
|
||||||
private void setSettings(JSONObject newSettings) {
|
private void setSettings(JSONObject newSettings) {
|
||||||
settings = newSettings;
|
settings = newSettings;
|
||||||
|
}
|
||||||
|
|
||||||
if (inBackground) {
|
/**
|
||||||
|
* Update the notification.
|
||||||
|
*/
|
||||||
|
private void updateNotifcation() {
|
||||||
|
if (isBind) {
|
||||||
stopService();
|
stopService();
|
||||||
startService();
|
startService();
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,13 @@
|
|||||||
[self disable:NULL];
|
[self disable:NULL];
|
||||||
[self configureAudioPlayer];
|
[self configureAudioPlayer];
|
||||||
[self configureAudioSession];
|
[self configureAudioSession];
|
||||||
|
[self observeLifeCycle];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the listener for pause and resume events.
|
* Register the listener for pause and resume events.
|
||||||
*/
|
*/
|
||||||
- (void) observeLifeCycle:(CDVInvokedUrlCommand *)command
|
- (void) observeLifeCycle
|
||||||
{
|
{
|
||||||
NSNotificationCenter* listener = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter* listener = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
|
@ -84,15 +84,6 @@ namespace Cordova.Extension.Commands
|
|||||||
Deactivate();
|
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>
|
/// </summary>
|
||||||
/// Startet das Aktualisieren des Standpunktes
|
/// Startet das Aktualisieren des Standpunktes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var exec = require('cordova/exec'),
|
var exec = require('cordova/exec'),
|
||||||
channel = require('cordova/channel');
|
channel = require('cordova/channel');
|
||||||
|
|
||||||
|
|
||||||
@ -27,10 +27,13 @@ var exec = require('cordova/exec'),
|
|||||||
document.addEventListener('backbutton', function () {}, false);
|
document.addEventListener('backbutton', function () {}, false);
|
||||||
|
|
||||||
channel.deviceready.subscribe(function () {
|
channel.deviceready.subscribe(function () {
|
||||||
// Registriert die Listener für die (sleep/resume) Events
|
|
||||||
cordova.exec(null, null, 'BackgroundMode', 'observeLifeCycle', []);
|
|
||||||
// Set the default settings
|
// Set the default settings
|
||||||
exports.configure();
|
exports.configure();
|
||||||
|
|
||||||
|
// Only enable WP8 by default
|
||||||
|
if (['WinCE', 'Win32NT'].indexOf(device.platform)) {
|
||||||
|
exports.enable();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user