Skip to content

Instantly share code, notes, and snippets.

@marvinlix
Created April 18, 2012 11:26
Show Gist options
  • Select an option

  • Save marvinlix/2412990 to your computer and use it in GitHub Desktop.

Select an option

Save marvinlix/2412990 to your computer and use it in GitHub Desktop.
LogActivity
package com.test.android;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class LogActivity extends Activity {
private String extendClassName = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
extendClassName = new Exception().getStackTrace()[1].getClassName();
onLog();
}
protected void onPause() {
super.onPause();
onLog();
}
protected void onRestart() {
super.onRestart();
onLog();
}
protected void onStart() {
super.onStart();
onLog();
}
protected void onStop() {
super.onStop();
onLog();
}
protected void onResume() {
super.onResume();
onLog();
}
protected void onDestroy() {
super.onDestroy();
onLog();
}
private void onLog() {
String methodName = new Exception().getStackTrace()[1].getMethodName();
Log.i("Lifecycle", extendClassName + " ---> " + methodName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment