View RSS Feed

Android Activity

  1. Android Activity Lifecycle

    by , 02-11-2012 at 10:00 AM
    All fundamental lifecycle methods of an activity are given in below code skeleton.

    Java Code: This is the code to manage lifecycle of an activity
    public class ExampleActivity extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // The activity is being created.
        }
        @Override
        protected void onStart() {
            super.onStart();
            // The activity is about to become visible.
    ...
  2. Starting an Android Activity for a Result

    by , 02-11-2012 at 09:56 AM
    Start the activity using startActivityForResult() when you want to get a result from the activity. Implement the onActivityResult() method to get the result from activity. In this method, subsequent activity will return result in Intent.

    In below code, we want to pick the contact.

    Java Code: This is the code to start an activity for a result
    private void pickContact() {
        // Create an intent to "pick" a contact, as defined by the content provider URI
        Intent intent = new Intent(Intent.ACTION_PICK,
    ...
  3. Starting an Android Activity

    by , 02-11-2012 at 09:53 AM
    startActivity() method is called when a new activity is started. Intent object is passed as parameter and it describes your activity. What actions you want to perform are described by this intent. Also data used by an activity is carried by this intent.

    For launching a new activity, create an intent that describes the activity using the class name. Following code explains how one activity can start a new activity.

    Java Code: This is the code to create a new Intent
    Intent intent = new Intent(this, SignInActivity.class);
    ...
  4. Android Activities

    by , 02-11-2012 at 09:44 AM
    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. ...
    Categories
    Android Activity