New method isActive to receive if mode is active

This commit is contained in:
Sebastián Katzer
2014-12-14 14:23:57 +01:00
parent fc6e6cf51d
commit 8f2c75321c
5 changed files with 66 additions and 25 deletions

View File

@@ -290,12 +290,18 @@ public class BackgroundMode extends CordovaPlugin {
eventName = "deactivate"; break;
default:
eventName = "failure";
}
final String js = String.format("setTimeout('%s.on%s(%s)',0)",
String active = event == Event.ACTIVATE ? "true" : false;
String flag = String.format("%s._isActive=%s;",
JS_NAMESPACE, active);
String fn = String.format("setTimeout('%s.on%s(%s)',0);",
JS_NAMESPACE, eventName, params);
final String js = flag + fn;
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {