I use a single static class in my code that defines a static field which I'm reusing between Activity onStop/onStart invocations. Here's a scenario:
At least one of my users reports the failure at step 3 which I cannot reproduce but which looks like reset of static data
Any suggestions?
That is not safe. Your process can be killed between onStop and onStart, so all static data will be gone. In fact your activity can even be killed before it gets to onStop. In your tests the process was not killed, but it was for the user. See the Android activity life cycle which has a nice flow chart showing the possibilities.
You need to store the data some other way, in prefs or database for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With