Tuesday, December 06, 2011
Activity In Android :
What is an Activity ?
What is an Activity ?
- User interface of an application displayed on a device through an activity.
- For each unique screen we have to create an activity.
- When we run any application on our device(android smartphones, mobile devices or tablet pc) and moving one screen to another screen then there is a bunch of activities works internally.
- There will be create a stack(called as backstack) and performing push-pop action with activities. When new activity creates , it pushed into backstack and poped from it by pressing "Back" button.
- When we want to create a new activity , we have to extend the "Activity" class.
Source Code of an Activity :
import android.app.Activity; import android.os.Bundle; public class MyFirstActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } }
Life Cycle of an Activity :
You can easily understand the life cycle of an activity by this figure :
Note :- Adding dashed lines for <<kill>> , those indicate that OS may kill the activity when resources are low, so onStop() and/or onDestroy() might not be called.

Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →
Related Posts:
Subscribe to:
Post Comments (Atom)
0 comments: