mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-12-23 13:57:35 +00:00
Allow app to move to background (Android)
This commit is contained in:
parent
af5da60143
commit
d012080d2b
@ -109,6 +109,11 @@ public class BackgroundMode extends CordovaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("background")) {
|
||||
moveToBackground();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("enable")) {
|
||||
enableMode();
|
||||
return true;
|
||||
@ -303,6 +308,16 @@ public class BackgroundMode extends CordovaPlugin {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send app to background.
|
||||
*/
|
||||
private void moveToBackground() {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
cordova.getActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire vent with some parameters inside the web view.
|
||||
*
|
||||
|
@ -99,6 +99,17 @@ exports.disableWebViewOptimizations = function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Move app to background (Android only).
|
||||
*
|
||||
* @return [ Void ]
|
||||
*/
|
||||
exports.moveToBackground = function () {
|
||||
if (device.platform == 'Android') {
|
||||
cordova.exec(null, null, 'BackgroundMode', 'background', []);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If the mode is enabled or disabled.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user