Android

Android Activities

Android Activities

Just like other programming languages such as C/C++, the Android system also initiates with a main activity. To do this, we use a callback method onCreate() and after that, a series of callback methods are called to start an activity. 

You can also refer to the image shown below from: https:www.android.com 

 

Android Activity lifecycle

 

The activity class is used to define various events. Let’s understand these methods below:

  • onCreate(): This is the first callback method called on the creation of an activity.
  • onStart(): This method is called when the activity starts and becomes visible to the user.
  • onRestart(): As the name suggests, the method is called when the activity restarts after stopping it. 
  • onResume(): This callback method is called when the user starts performing an activity with the application. 
  • onPause(): This method is used to pause the activity when the user is no more interacting with the application. 
  • onStop(): The method is called when the activity is stopped and the application is no longer visible to the user. 
  • onDestroy(): This callback method is initiated when the activity is destroyed by the system due to some error or by the user. 

 

Top course recommendations for you

    Factorial Program in C
    2 hrs
    Beginner
    4.5K+ Learners
    4.42  (154)
    Jenkins Tutorial
    1 hrs
    Beginner
    8.4K+ Learners
    4.49  (575)
    Dockerize Spring Boot Application
    1 hrs
    Intermediate
    3.8K+ Learners
    4.4  (243)
    Python Data Structures
    1 hrs
    Beginner
    30.3K+ Learners
    4.51  (2109)
    Fibonacci Series in Java
    2 hrs
    Beginner
    2.7K+ Learners
    4.33  (58)
    Priority Queue in C++
    1 hrs
    Beginner
    2.2K+ Learners
    4.3  (97)
    Introduction to MATLAB
    2 hrs
    Beginner
    21.8K+ Learners
    4.42  (1620)
    Packages in Python
    1 hrs
    Beginner
    7.1K+ Learners
    4.38  (449)
    Palindrome in Python
    2 hrs
    Beginner
    2.8K+ Learners
    4.63  (83)