3

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.)

teynon
  • 7,540
  • 10
  • 63
  • 106

2 Answers2

1

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

Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251
1

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.

Ravi Vyas
  • 12,212
  • 6
  • 31
  • 47