by, 02-11-2012 at 09:44 AM (553 Views)
A single screen in Android application is provided by an activity. You can move these Activities into background and then resume.
It is just like a screen where a user interacts and performs some actions such as dial the phone, view map, send email, take a phone etc. User interface is drawn into an Activity window. Screen is usually filled by the window or it may float on top of different other windows.
Different bounded or integrated activities create an application. One of these activities is a main activity and it is launched as the main screen when user starts application. Different actions are performed by calling these different activities. Last activity is stopped whenever a new one is called and system stores the activity in a stack. This stack follows the basic queue mechanism “last in. first out”.
Through the activity’s life cycle callback methods, an activity is notified of the change that it is stopped. An activity may receive different callback methods. For example
- System is creating it
- Stopping it
- Resuming it
- Destroying it
Creating an Activity
Create a subclass of Activity. Implement the callback methods as these methods are called between transitions. Following are the important methods.
- onCreate(): This method is called when creating an activity. In this method you can initialize initial components.
- onPause(): This is called when user is leaving activity. In this method you can commit changes.