Android – Activity and lifecycle states Part 1

activiy and lifecycle states, <span>Android – Activity and lifecycle states Part 1</span>, KandZ
activity Lifecycle

Activity is the most common component in Android app and the most crucial. It is usually used to display information to the device screen but there also times that you do not have to provide a user interface with an activity. To implement an activity you need to follow some steps:

  • Extend the Ativity class
  • Override selected lifecycle/hook methods, those at the picture above
  • define other methods or nested classes needed to implement the activity
  • update the AndroidManifest.xml file to include the activity so Android OS knows about it.

Lifecycle

An activity extends the Activity class which has lifecycle/hook methods that are called automatically when an event occurs. Those events are activity’s lifecycle events:

  • initialized – activity initialized and onCreate() is called.
  • created – activity created, it not visible neither is has focus. onStart() and onRestart() are called.
  • Started No focus but visible, onResume() is called
  • Resumed Has focus and it is visible. The activity can also be paused when another activity opens above it and destroyed by clicking the back button.
  • Destroyed It is destroyed and OS can removed it from memory

END OF PART 1!!!

91860cookie-checkAndroid – Activity and lifecycle states Part 1Android – Activity and lifecycle states Part 1

Related posts

5 Thoughts to “Android – Activity and lifecycle states Part 1

  1. […] Android – Activity and lifecycle states Part 1 […]

  2. […] Android – Activity and lifecycle states Part 1 […]

  3. […] can read PART 1 here. You can launch activities on demand with startActivity() and […]

  4. […] Android – Activity and lifecycle states Part 1 […]

Comments are closed.