mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2025-12-15 10:53:22 +00:00
Allow app to move to background (Android)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user