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 −

Xamarin - Android Activity Lifecycle



Frequently Asked Questions

+
Ans: Xamarin - Android Resources view more..
+
Ans: Xamarin - Application Manifest view more..
+
Ans: Xamarin - First Application view more..
+
Ans: Xamarin - Android Activity Lifecycle view more..
+
Ans: Xamarin - Permissions view more..
+
Ans: Xamarin - Building the App GUI view more..
+
Ans: Xamarin - Menus view more..
+
Ans: Xamarin - Layouts view more..
+
Ans: Xamarin - Android Widgets view more..
+
Ans: Xamarin - Android Dialogs view more..
+
Ans: Xamarin - Gallery view more..
+
Ans: Xamarin - Andriod Views view more..
+
Ans: Xamarin - Multiscreen App view more..
+
Ans: Xamarin - Deploying Your App view more..




Rating - NAN/5
500 views

Advertisements