Assignment# 2: Riphah International University
Assignment# 2: Riphah International University
Assignment# 2
Date: 04/03/2020 Deadline: 09/03/2020
Q: Create an android application with only one activity, override all lifecycle methods
studied in the class. Then you must execute the application and try different cases to
observe which of the lifecycle methods are being called.
i.e., When we press back button, which of the lifecycle methods are being called?
Note: You can use Log class to print the debugging messages and observe them using
Logcat tool provided within Android Studio.
Solution:
Code:
public class ExampleActivity extends Activity {
@Override
@Override
@Override
@Override
@Override
}
Riphah International University
Department of Software Engineering
Faculty of Computing
Example Case: Pressing Back Button and Coming back to the Activity.
When activity is launched for the first time, the methods called are
1. onCreate()
2. onStart()
3. onResume()
When back button is pressed while activity is running, the methods called are
4. onPause()
5. onStop()
6. onDestroy()
_________________________END_____________________________