Sample code for life cycle of activities in Android