I need to debug my application and debug the code is part of Runnable
and do some actions in application then debug the code again, but I can't do it, I can't do any actions as debug point is fired immediately.
code :
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 .
}
For runnables/async tasks etc it is useful to call Debug.waitForDebugger()
, prior the code you set the breakpoint on:
...
Debug.waitForDebugger();
foo.bar(); # breakpoint on this line
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With