Created
April 18, 2012 11:26
-
-
Save marvinlix/2412990 to your computer and use it in GitHub Desktop.
LogActivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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