mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-11-24 16:24:53 +00:00
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,
|
||||
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();
|
||||
}
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user