Android Javascript Ajax Html PHP Example
Need a Website Or Web Application Contact : +91 9437911966 (Whatsapp) Note: Paid Service

Working with Multiple Activities android


In this module, you will learn about

  1. Component activation
  2. Android Life cycle
  3. Launching a specific Activity
  4. Implicit Intent
  5. Pass data to another activity

Component Activation:

In android, each app component are the entry point for the system or user can enter your app. Those are essential building blocks of an android application.

  • Such As: Activities
  • Services
  • Broadcast receiver
  • Content providers

Now let’s start with Android Life Cycle.

So before proceeding towards the android example let’s find out the flow chart of the android life cycle.

The Activity class provides a number of callbacks that allow the activity to know that a state has been changed: that the system is creating, stopping, or resuming an activity, or destroying the process in which the activity resides.

when the system first launches the activity, you must implement the onCreate method.

Inside this onCreate method, you perform basic operation that should happen only once for the entire life of the activity.

After the onCreate method activity enters the started state and the system calls the onStart method.

In the onStart method, activity is visible to the user and it prepares the activity to enter the foreground and become interactive, where the app initializes the code that maintains the UI and once, when this callback finishes, the activity enters the onResume state.

When the activity enters the resumed state, it comes to the foreground. This is a state in which the app interacts with the users. It keeps active until something happens to take focus away from the activity.

For example: To navigate another activity
receiving a phone call
or the device screen turns off.

If another activity comes to the foreground then onPause method is called and it performs when the activity enters into the resumed state.

If the shorter span of time activity navigates to the same activity then it calls the onResume method.

If the activity is no longer active or about to terminate, the system calls the onStop method,

At the onStop method, there are two conditions, when the other application has opened, then the processor tries to kill the app, to free the memory.

If your app doesn’t kill by the processor, then it navigates you to restart method which calls the onStart method then it goes in the same as well.

And when processor kills the app to free the memory, then it navigates you to the onCreate method.

If your app is closed or shut down by the user then it calls the onDestroy method.

Inside this event, the activity is finishing due to finish method being called on the activity.

And then the activity closed.

So in the next lesson, we are going to show you practically how it works by doing an android example.