Tuesday, September 21, 2010

Activity in android

      Activity is important ui unit of android application.

To start an activity from another, you have to use an intent by sending the new activity class as parameter.

e.g.
         Intent i = new Intent(this, NewActivity.class);


Next you call startActivity method

     startActivity(i);

You can pass extra data to the new actiivity by using putExtra method.


   i.putExtra( "Title",mTitle);


In the new activity, you can extract this information using getExtra methods

   Intent i = getIntent();
   String t = i.getStringExtra("Title");

      

No comments:

Post a Comment