- Sometimes attaching to a process isn't the ideal way to trace code.
- Sometimes you're just unsure whether a function gets called or not.
- Throwables come in handy.
Step 1: Declare Throwable and feed it to Log.d(TAG, MSG, Throwable)
package com.elinlin010.backtracingdemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class BrokenAppActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_broken_app);
Throwable t = new Throwable();
t.fillInStackTrace();
Log.d("010", "", t);
}
}
Step 2: See it in logcat.
留言
張貼留言