mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-13 01:43:24 +00:00
Fix main thread bug
This commit is contained in:
@@ -42,6 +42,9 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
ACTIVATE, DEACTIVATE, FAILURE
|
ACTIVATE, DEACTIVATE, FAILURE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plugin namespace
|
||||||
|
private static final String JS_NAMESPACE = "cordova.plugins.backgroundMode";
|
||||||
|
|
||||||
// Flag indicates if the app is in background or foreground
|
// Flag indicates if the app is in background or foreground
|
||||||
private boolean inBackground = false;
|
private boolean inBackground = false;
|
||||||
|
|
||||||
@@ -247,10 +250,14 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String js = String.format("setTimeout('cordova.plugins.backgroundMode" +
|
final String js = String.format("setTimeout('%s.on%s(%s)',0)",
|
||||||
".on%s(%s)',0)",
|
JS_NAMESPACE, eventName, params);
|
||||||
eventName, params);
|
|
||||||
|
|
||||||
webView.loadUrl("javascript:" + js);
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
webView.loadUrl("javascript:" + js);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user