Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2016 01:02
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 48 You must be signed in to fork a gist
  • Save anonymous/8f1c6e624a5374a51dac6d5b1e58cae6 to your computer and use it in GitHub Desktop.
Save anonymous/8f1c6e624a5374a51dac6d5b1e58cae6 to your computer and use it in GitHub Desktop.
Activity Lifecycle exercise
package com.example.android.lifecycle;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.v("MainActivity", "onCreate");
}
@Override
protected void onStart() {
super.onStart();
Log.v("MainActivity", "onStart");
}
@Override
protected void onResume() {
super.onResume();
Log.v("MainActivity", "onResume");
}
@Override
protected void onPause() {
super.onPause();
Log.v("MainActivity", "onPause");
}
@Override
protected void onStop() {
super.onStop();
Log.v("MainActivity", "onStop");
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.v("MainActivity", "onDestroy");
}
}
@ebnrdwan
Copy link

ebnrdwan commented Sep 6, 2016

doesn't appear any thing on the logcat !! ?
any hint to solve this ?

@sunnychugh
Copy link

it must be showing something at least if not logcat..what its showing>???

@karabulut1989
Copy link

Check if your package name is okay or any red error indication.
You should see this first three logs:
02-24 16:32:07.377 31979-31979/com.example.android.activitylifecycle V/MainActivity: onCreate
02-24 16:32:07.378 31979-31979/com.example.android.activitylifecycle V/MainActivity: onStart
02-24 16:32:07.380 31979-31979/com.example.android.activitylifecycle V/MainActivity: onResume

Hope you fixed it :)

@ChandraniChatterjeeMolly

@ebnrdwan there must be something displayed on the logcat. Try re-running.

@nayantiwariofficial
Copy link

nayantiwariofficial commented May 26, 2017

@ebnrdwan sometimes Android Studio does that. Restarting the studio helped me several times.

Hope this helps.

@Aseel-Khatri
Copy link

I think ur logcat was set except Verbose
logdemo

@louayeldin
Copy link

Helpful

@abdullahelsheikh
Copy link

Thanks

@arp-wtm
Copy link

arp-wtm commented Apr 16, 2018

use log.i

@ID2GO
Copy link

ID2GO commented Apr 26, 2018

Works fine with log.v

@shaero
Copy link

shaero commented Jun 25, 2018

use logo

@Htewech7
Copy link

It's work, i try it, thanks devemoper

@leocruzdev
Copy link

Nice!!!!

@djalilo24
Copy link

Thanks

@Pial-shp
Copy link

thank you :)

@FTW-Khushal
Copy link

I WAS HERE......

@Vipxpert
Copy link

And also, don't disable logging in develeper option on phone

@sanmeshkakade
Copy link

Lol! learning this course in 2021!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment