Download this Blogger Template by Clicking Here!

Ad 468 X 60

Share

Widgets

Tuesday, December 06, 2011

Widgets

Activity In Android :


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.

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →

0 comments: