Reputation: 8585
Is there an event on application opening, for example when I open previous opened and closed by the home key application from the last applications menu.
Upvotes: 0
Views: 567
Reputation: 4981
When talking about application in general, you can implement an Application class, where you override its onCreate() callback method, which is called every time application starts. When talking about Activity class instances, use Activity class callback methods to check if current Activity comes to foreground (becomes visible to user). For example, you may need to implement onResume() and/or onStart() lifecycle callback methods.........
Android Application class does not have onResume() method. Actually user sees and interacts with activities (even if they use dialogs or fragments). Application in general may not contain only activities, but services, content providers and broadcast receivers as well. So if you'd like, you can implement onResume() method yourself in the particular application class and call it from Activity's onResume() (or onStart()). Of course, it's not convinient to make such a call from every activity in your application. Therefore it makes sense to implement some BaseActivity (which extends Activity) and subclass it by every application activity.
Upvotes: 1
Reputation: 4119
You should definitely read about lifecycle on Android: http://developer.android.com/training/basics/activity-lifecycle/starting.html
Upvotes: 1