3.3 Android Activities: Page 2 of 2

Open the menu and find your application in the emulator. Remember, the emulator is a virtual device. The App  would be installed just like other native applications.

          Figure ActivityTest App

                                        Figure  ActivityTest App 

  1. Now open the LogCat of your IDE and keep an eye on it. As soon as you click on the icon of your application, app will launch. See the LogCat you will find lines saying

com.Debosmita….      Events                      onCreate()  event

com.Debosmita….      Events                      onStart()  event

com.Debosmita….      Events                      onResume()  event

This is the sequence of our callback methods when we launched our app for the first time.

Figure App is launched for the first time

                               Figure App is launched for the first time

    

  1. Now press the home button and see the changes in LogCat. You will see onPause() and onStop()  events as shown below

com.Debosmita….      Events                      onPause()  event

 .................... 

com.Debosmita….      Events                      onStop()  event

                                            Figure After Pressing the Home button

4.  Again click on the  ActivityTest icon. The callback methods are not the same with respect to the sequence observed when the activity was called for the first time. The sequence would be as follows:

 

com.Debosmita….      Events                      onRestart()  event

com.Debosmita….      Events                      onStart()  event

com.Debosmita….      Events                      onResume()  event

      This implies our app is still alive and pushed down to back stack and hence it is not visible.

 

                    Figure After re-launching the app.

                                          Figure After re-launching the app.

5.    Now press the back button. Again, follow the changes. Now app is going to be killed. Hence you can see onDestroy() event is going to appear in call sequence. The sequence of callback methods will be as follows:

com.Debosmita….      Events                      onPause()  event

 .................

 .................

​                   com.Debosmita….      Events                      onStop()  event

com.Debosmita….      Events                      onDestroy()  event

                              Figure - App is going to be killed.