android activity lifecycle in android studio

0 176

android activity lifecycle tutorial

what is activity lifecycle in android

If you have worked with C# or Java then you will be familiar that your program starts from main method/function same way android system loads its App’s within android activity using android oncreate callback function. There is sequence of method to control android activity life cycle. You don’t need to implement all these methods to control activity life cycle but it’s important to understand each and every life cycle of activities .activity class in android define all callback methods to handle life cycle of android application.

life cycle of activity

when the user starts app activity it’s come to the foreground and receive user interact with your app ,during this process android activity lifecycle calls different activity cycle method from a system in which you set up the user interface and other components.If user start or switch to another app then your app will be no longer visible but it is in background all this process will be handled with android app activity methods but the instance and its state remain intact          

life cycle of an android application

when user starts apps it is ready and in running mode while using app if user switch to another app then your app will be in background but no longer visible as user return back to your app it will be again in running mood and everything user will get same from where user left and went to another app, as user press back button app still will be alive in background if user won’t come back to your app then after sometimes android system will automatically remove your app from stack and app is closed and android application life cycle destroyed . service life cycle in android is different than life cycle of an activity in android          

activity lifecycle in android from start to till end

There is three loop in android app life cycle

  1. The entire life time of app starts the first call of oncreate bundle till simple final call to ondestroy android method
  2. The visible lifetime of activity starts from android onstart method until a corresponding call to onstop android method
  3. The foreground lifetime starts from android onresume methods till an activity happens between a call to android onpause method

activity diagram for android application

 

 

Download source code from here

Comments

comments

Leave A Reply

Your email address will not be published.