forked from Github/cordova-plugin-run-in-background
Fix app going to sleep when device locked
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user