SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Activity 
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. 
An application usually consists of multiple 
activities that are loosely bound to each other.
Activity 
Each time a new activity starts, the 
previous activity is stopped, but the 
system preserves the activity in a stack . 
When a new activity starts, it is pushed 
onto the back stack and takes user 
focus.
Go Phish! 4 
Android 
Activity - >
Activity life 
cycle - >
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 
Go Phish! 6 
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: 
If an activity in the foreground of 
the screen (at the top of the stack), 
it is active or running. 
If an activity is completely obscured 
by another activity, it is stopped. 
If an activity has lost focus, it 
is paused. 
If an activity is paused or stopped, 
the system can drop the activity 
from memory by either asking it to 
finish, or simply killing its process.
Android activity lifecycle

Weitere ähnliche Inhalte

Was ist angesagt?

Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
Android life cycle
Android life cycleAndroid life cycle
Android life cycle
瑋琮 林
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
Jacky Lian
 
Android resource
Android resourceAndroid resource
Android resource
Krazy Koder
 

Was ist angesagt? (20)

Android activity
Android activityAndroid activity
Android activity
 
Notification android
Notification androidNotification android
Notification android
 
Android resources
Android resourcesAndroid resources
Android resources
 
Android UI
Android UIAndroid UI
Android UI
 
Android life cycle
Android life cycleAndroid life cycle
Android life cycle
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Anatomy of android application
Anatomy of android applicationAnatomy of android application
Anatomy of android application
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Android Components
Android ComponentsAndroid Components
Android Components
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Event handling
Event handlingEvent handling
Event handling
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Android resource
Android resourceAndroid resource
Android resource
 

Andere mochten auch

Andere mochten auch (20)

Google android Activity lifecycle
Google android Activity lifecycle Google android Activity lifecycle
Google android Activity lifecycle
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
The android activity lifecycle
The android activity lifecycleThe android activity lifecycle
The android activity lifecycle
 
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aAndroid Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaAndroid | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material Design
 
Android custom listview
Android custom listviewAndroid custom listview
Android custom listview
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
Post-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android EcosystemPost-PC: Geolocation & Maps in the Android Ecosystem
Post-PC: Geolocation & Maps in the Android Ecosystem
 
Logcatの話
Logcatの話Logcatの話
Logcatの話
 
Multimedia on android
Multimedia on androidMultimedia on android
Multimedia on android
 
Persistence in Android
Persistence in AndroidPersistence in Android
Persistence in Android
 
Android Custom view
Android Custom view Android Custom view
Android Custom view
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
 
Open Ldap Integration and Configuration with Lifray 6.2
Open Ldap Integration and Configuration with Lifray 6.2Open Ldap Integration and Configuration with Lifray 6.2
Open Ldap Integration and Configuration with Lifray 6.2
 
Json vs Gson vs Jackson
Json vs Gson vs JacksonJson vs Gson vs Jackson
Json vs Gson vs Jackson
 

Ähnlich wie Android activity lifecycle

android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
aswinbiju1652
 
Android activity
Android activityAndroid activity
Android activity
MohNage7
 
Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
DHIRAJ PRAVIN
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
Ahsanul Karim
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)
TECOS
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
Ahsanul Karim
 

Ähnlich wie Android activity lifecycle (20)

android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
 
Activities
ActivitiesActivities
Activities
 
Android activity
Android activityAndroid activity
Android activity
 
Mad textbook 63-116
Mad textbook 63-116Mad textbook 63-116
Mad textbook 63-116
 
Android activity
Android activityAndroid activity
Android activity
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
 
Day 4: Activity lifecycle
Day 4: Activity lifecycleDay 4: Activity lifecycle
Day 4: Activity lifecycle
 
Android development session 2 - intent and activity
Android development   session 2 - intent and activityAndroid development   session 2 - intent and activity
Android development session 2 - intent and activity
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)
 
The activity class
The activity classThe activity class
The activity class
 
The activity class
The activity classThe activity class
The activity class
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
 
Voices That Matter: JavaScript Events
Voices That Matter: JavaScript EventsVoices That Matter: JavaScript Events
Voices That Matter: JavaScript Events
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
 

Kürzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

Android activity lifecycle

  • 1.
  • 2. Activity 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. An application usually consists of multiple activities that are loosely bound to each other.
  • 3. Activity Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack . When a new activity starts, it is pushed onto the back stack and takes user focus.
  • 4. Go Phish! 4 Android Activity - >
  • 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 Go Phish! 6 destroyed. nothing
  • 7. 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()
  • 8. Activity Stack • Activities in the system are managed as an activity stack. An activity has essentially four states: If an activity in the foreground of the screen (at the top of the stack), it is active or running. If an activity is completely obscured by another activity, it is stopped. If an activity has lost focus, it is paused. If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process.