Xamarin – Android Activity Lifecycle


Xamarin – Android Activity Lifecycle


”;


When a user navigates through an Android App, a series of events occurs. For example, when a user launches an app, e.g., the Facebook App, it starts and becomes visible on the foreground to the user, onCreate() → onStart() → onResume().

If another activity starts, e.g., a phone call comes in, then the Facebook app will go to the background and the call comes to the foreground. We now have two processes running.

onPause()  --- > onStop()

When the phone call ends, the Facebook app returns to the foreground. Three methods are called.

onRestart() --- > onStart() --- > onResume()

There are 7 lifecycle processes in an Android activity. They include −

  • onCreate − It is called when the activity is first created.

  • onStart − It is called when the activity starts and becomes visible to the user.

  • onResume − It is called when the activity starts interacting with the user. User input takes place at this stage.

  • onPause − It is called when the activity runs in the background but has not yet been killed.

  • onStop − It is called when the activity is no longer visible to the user.

  • onRestart − It is called after the activity has stopped, before starting again. It is normally called when a user goes back to a previous activity that had been stopped.

  • onDestroy − This is the final call before the activity is removed from the memory.

The following illustration shows the Android Activity Lifecycle −

Android Activity Lifecycle

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *