Write Listener When Application Close
Solution 1:
Looking at the documentation :
http://developer.android.com/reference/android/app/Application.html
It seems the Application
class has no capabilities to do that. (dont get confuse with onTerminate
).
The problem is, why dont you write the code you want to run in onDestroy
of your Activity
?
What is your case, so destroying the Activity
does not mean closing the Application
?
You might consider to read this :
Solution 2:
The short answer is ... there aren't!
The concept of "application close" is very diffuse: An application is a set of activities, services, etc... and a lot of things may keep the application alive.
You can't even guess when (or if) an activity onStop()
and onDestroy()
will be called.
Even calling activity.finish()
doesn't mean any of those methods would be called instantly. Take a look at http://developer.android.com/training/basics/activity-lifecycle/stopping.html .
But there's sure a better place to do those things you have to do. What is it?
Post a Comment for "Write Listener When Application Close"