Skip to content

Instantly share code, notes, and snippets.

@yeojoy
Created July 15, 2015 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeojoy/94fc16bacb274e9bb638 to your computer and use it in GitHub Desktop.
Save yeojoy/94fc16bacb274e9bb638 to your computer and use it in GitHub Desktop.
Android Log line number
private void show() {
StringBuilder sb = new StringBuilder();
StackTraceElement ste = null;
int j = Thread.currentThread().getStackTrace().length;
for (int index = 0; index < j; index++) {
ste = Thread.currentThread().getStackTrace()[index];
if (ste == null) continue;
// ste 내부 내용 출력.
sb.append("index : ").append(index).append("\n");
sb.append("Class Name : ").append(ste.getClassName()).append("\n");
sb.append("File Name : ").append(ste.getFileName()).append("\n");
sb.append("Line Number : ").append(ste.getLineNumber()).append("\n");
sb.append("Method Name : ").append(ste.getMethodName()).append("\n");
sb.append("isNativeMethod : ").append(ste.isNativeMethod()).append("\n");
sb.append("toString() : ").append(ste.toString()).append("\n\n\n");
}
((TextView) findViewById(R.id.tv_result)).setText(sb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment