开发者

clear values on exit in android

开发者 https://www.devze.com 2023-04-03 18:07 出处:网络
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开发者_如何

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;
//...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消