Applications behave differently after exiting and re-entering
Cordova, version 3.5.0-0.2.6
<body><script>
alert("documentready");
document.addEventListener("deviceready", function() {
alert("deviceready");
}, false);
</script></body>
I enter the application after deployment and get “Document ready” and “Device ready” alerts.
I use the back button to leave the app.
I only get “File ready”.
I get both alerts when I use Task Manager to force close an application or redeploy it.
I expect this behavior to also occur after re-entering the app normally.
I
prefer a solution, after I left, there was no evidence that the app had been opened before. No recovery from garbage collection, etc. Ideally, perform the same logs as the force shutdown method in Task Manager.
Ok: I guess exactly the same happens when I close my app via the back button, just like I open the task manager and force my app to close. Is this at least theoretically possible?
Or, I
want the app to be in a “hibernate-like” state when it leaves via the back button, and if I re-enter it, it behaves absolutely as if it never left (calling the same logic as when pressing the menu/home button).
The question remains open – earn a 50RS bounty
Solution
Add this to your mainActivity .java
regardless of how it is called in your project:
@Override
public void onBackPressed() {
finish();
}