Different States of an Android Activity

+122 Bucky Roberts · December 19, 2014
/images/forum/upload/2014-12-19/5a00eeefae97a8d127f621fdc5ad2ff7.png


   @Override
   protected void onStart() {
       super.onStart();
       Log.i(TAG, "onStart");
   }


   @Override
   protected void onResume() {
       super.onResume();
       Log.i(TAG, "onResume");
   }


   @Override
   protected void onPause() {
       super.onPause();
       Log.i(TAG, "onPause");
   }


   @Override
   protected void onStop() {
       super.onStop();
       Log.i(TAG, "onStop");
   }


   @Override
   protected void onRestart() {
       super.onRestart();
       Log.i(TAG, "onRestart");
   }


   @Override
   protected void onDestroy() {
       super.onDestroy();
       Log.i(TAG, "onDestroy");
   }


   @Override
   protected void onSaveInstanceState(Bundle outState) {
       super.onSaveInstanceState(outState);
       Log.i(TAG, "onSaveInstanceState");
   }


   @Override
   protected void onRestoreInstanceState(Bundle savedInstanceState) {
       super.onRestoreInstanceState(savedInstanceState);
       Log.i(TAG, "onRestoreInstanceState");
   }

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
+2 jan burg · December 19, 2014
Thanks man, this is pretty useful. Is this some foreshadowing of some new android/java development tutorials to look forward to? :)
0 Troy Jones · December 19, 2014
I seen this on the developers site.  I believe it mentioned something about only needing to use onStop(), onStart() and onDestroy() as the other one's the activity automatically cycles through.
0 Samiul Masuk · February 10, 2015
:)
0 Sharad Gupta · February 22, 2015
Thanks for the Source Code. Just began watching tutorials. They are awesome :) !!
+5 Carl Barlow · March 1, 2015
onDasher(), onDancer(), ...
Took me a while to find this post with the source code, but otherwise I'm loving this video series!
+1 Kenny Dexter · March 17, 2015
WOw......and What a Wow

onBucky()

your tutorials are dope , i'm just speechless!:sick:
+2 Shreyans Mulkutkar · March 18, 2015
I added Log messages to my source code, but don't know why its not throwing onCreate, onStart, etc. messages when my App comes up on my emulater. Even added the log message filter. Still not seeing it. 
Can someone point out what is that thing I'm doing wrong?
Thanks in advance.
0 Lasith Niroshan · April 9, 2015
Thanks for codings...:)
0 Oleg Zigalenko · April 15, 2015
Hi Shreyans Mulkutkar. I had a similar problem and I could not see the log messages. After doing a little research this is what worked for me: 

-Change Log Level from Verbose to Debug
-Change Log Level from Debug to Verbose (basically it just resets it)
  (Make sure that your filter is set to your correct name that you created)
-Then click the Restart button on the left side of the log window (looks like a gray box with green arrow)
It will restart the log and wait about 10 seconds and it should show up. 

If it still does not work then please look at this link as it has more solutions to the same problem. 

http://stackoverflow.com/questions/17432358/android-studio-logcat-nothing-to-show

Good luck and happy coding. 
0 Sandesh uttarwar · June 14, 2015
thank you for this...!

Java / Android Development

103,697 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator