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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action.equalsIgnoreCase("background")) {
|
||||||
|
moveToBackground();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (action.equalsIgnoreCase("enable")) {
|
if (action.equalsIgnoreCase("enable")) {
|
||||||
enableMode();
|
enableMode();
|
||||||
return true;
|
return true;
|
||||||
@ -303,6 +308,16 @@ public class BackgroundMode extends CordovaPlugin {
|
|||||||
thread.start();
|
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.
|
* 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.
|
* If the mode is enabled or disabled.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user