Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - App Minimization Handling

I don't believe it is called minimization, but basically when the user navigates away from my game, is there an easy way to pause it? The only thing I know of is bundles, IE restoreState(Bundle savedState)

The problem is, I find myself trying to all sorts of logic problems on variables like this:

xGrid = new float[savedState.getFloatArray("xGrid").length];
yGrid = new float[savedState.getFloatArray("yGrid").length];
xGrid = savedState.getFloatArray("xGrid");
yGrid = savedState.getFloatArray("yGrid");

Is there an easier way like just stopping the thread and resuming it when they return? This is awfully annoying, considering my app is still in development and I have to update this every time I add a variable. I know i'm a lazy programmer, but... that's the point of programming right? (To be lazy.)

like image 359
teynon Avatar asked Dec 21 '25 22:12

teynon


2 Answers

There is no easy way tom , you will need to store all your data , possibly even to a file/database and it will be a great feature to return to a game after a few days , even after a restart.

The reason you have to store data is Android handles the memory,due to which it can decide to kill your app in an attempt to free memory.

like image 105
Ravi Vyas Avatar answered Dec 23 '25 11:12

Ravi Vyas


Check out Activity.onPause() and Activity.onResume(). If you need to save persistent state, check out the docs on that.

like image 23
Mohit Deshpande Avatar answered Dec 23 '25 10:12

Mohit Deshpande



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!