Fix app going to sleep when device locked

This commit is contained in:
Sebastián Katzer
2016-08-17 11:14:47 +02:00
parent 6297b9aea3
commit 830c4a97ad
4 changed files with 50 additions and 92 deletions

View File

@@ -21,12 +21,6 @@
package de.appplant.cordova.plugin.background;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
@@ -34,6 +28,12 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class BackgroundMode extends CordovaPlugin {
// Event types for callbacks
@@ -230,15 +230,15 @@ public class BackgroundMode extends CordovaPlugin {
private void startService() {
Activity context = cordova.getActivity();
Intent intent = new Intent(
context, ForegroundService.class);
if (isDisabled || isBind)
return;
Intent intent = new Intent(
context, ForegroundService.class);
try {
context.bindService(
intent, connection, Context.BIND_AUTO_CREATE);
context.bindService(intent,
connection, Context.BIND_AUTO_CREATE);
fireEvent(Event.ACTIVATE, null);
@@ -282,9 +282,6 @@ public class BackgroundMode extends CordovaPlugin {
private void fireEvent (Event event, String params) {
String eventName;
if (updateSettings != null && event != Event.FAILURE)
return;
switch (event) {
case ACTIVATE:
eventName = "activate"; break;