开发者

How to detect if my application closes

I want to save my all data to sdcard when my application closes, i've write a class to save my all data but i cannot detect when/where my aplication close or terminate event so i开发者_如何转开发 do not know where should i call my Data save class.

Thanks for any help.


How about making your own base class that extends Activity and override the onPause, onStop, and onDestroy methods there, then make your activities extend your new base class?


When your Activity is closed, it's onPause(), onStop() and onDestroy() methods will be called, so simply override one of them and save it there.

Check this out: http://developer.android.com/reference/android/app/Activity.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜