Android activity lifecycle

10,446 views 9 slides Sep 17, 2014
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map.
Each activity is given a window in which to draw its user interface. The window typically fills the screen, but m...


Slide Content

Android Activity Lifecycle

Activity

Activity

Go Phish! 4 Android Activity - >

Activity l ife cycle - >

Go Phish! 6 Method Description Next onCreate() Called when the activity is first created. onStart() onRestart() Called after your activity has been stopped, just prior to it being started again. Always followed by onStart() onStart() onStart() Called when the activity is becoming visible to the user . Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden. onResume()or  onStop() onResume() Called when the activity will start interacting with the user. Always followed by onPause(). onPause() onPause() Called when the system is about to start resuming a previous activity. onResume() or onStop() onStop() Called when the activity is no longer visible to the user. Followed by either onRestart() if this activity is coming back to interact with the user, or onDestroy() if this activity is going away. onRestart() or onDestroy() onDestroy() The final call you receive before your activity is destroyed. nothing

Example: When the Activity  first time loads  the events are called as below: onCreate () onStart () onResume() When you  click on Phone button  the Activity goes to the background and the below events are called: onPause() onStop() Exit the phone dialer  and the below events will be called: onRestart () onStart () onResume() When you click the  back button  OR try to  finish()  the activity the events are called as below: onPause () onStop () onDestroy ()

Activity Stack Activities in the system are managed as an  activity stack . An activity has essentially four states:
Tags