【问题标题】:Debug android application with break point in Runnable [Android Studio]在 Runnable [Android Studio] 中使用断点调试 android 应用程序
【发布时间】:2015-05-06 13:18:12
【问题描述】:

我需要调试我的应用程序并调试代码是Runnable 的一部分并在应用程序中执行一些操作然后再次调试代码,但我不能这样做,我不能做任何操作,因为调试点是立即开除。

代码:

public class UpdateHandler {

    public static Handler getHandler() {
        if (sHandler == null) {
            HandlerThread looper = new HandlerThread("update Handler");
            looper.start();
            sHandler = new Handler(looper.getLooper());
        }

        return sHandler;
    }
}


UpdateHandler.getHandler().post(new Runnable() {
    @Override
    public void run() {
        update();
    }
});

public void update() {
    // i put the debug point here .
}

【问题讨论】:

    标签: android debugging android-studio breakpoints runnable


    【解决方案1】:

    对于可运行/异步任务等,调用Debug.waitForDebugger()之前您设置断点的代码很有用:

    ...
    Debug.waitForDebugger();
    foo.bar();               # breakpoint on this line
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-30
      • 2013-05-21
      • 2018-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 2013-10-31
      相关资源
      最近更新 更多