i have some static integer variables in my android application.I am testing the application in emulator.When i click back and return to homescreen and launch the application again, the prev开发者_如何学编程ious values still persist and new values are added to it instead of overriding.So what is the procedure to clear these values when i close the application. I have tried with onRestart()
and onStop()
methods and reset the counter but it dint work.
How do i overcome this issue
In the onResume()
you can call an init()
method, for example :
void init()
{
myStaticVar = 0;
//...
}
精彩评论