Debugger disconnects when calling external intent

2019-05-17 01:58发布

问题:

I am trying to debug my app because something is happening from when I call the camera intent to when it takes the picture and my app is force closing on the way back. The problem is that the debugger disconnects immediately when the camera intent is called and I can no longer debug my app. I'm debugging on a device and not the emulator. I came across this solution in Google, but it doesn't seem to work. http://groups.google.com/group/android-developers/browse_thread/thread/6d6b5fa7819e4d74. Does anybody know how to get around this? The debugger should not disconnect when you call an external intent...I mean your app is still running. I just need to know how to keep debugging when I launch an external intent.

Thanks, Ed

回答1:

I just have the same issue when calling the gallery to browse for photos. The solution provided in the link you mentioned worked perfectly for me. write this code block in OnActivityResult method:

if (!Debug.isDebuggerConnected()){
    Debug.waitForDebugger();
    Log.d("debug", "started"); // Insert a breakpoint at this line!!
}

and put a breakpoint in the Log line specified as the comment says. When the execution return from the called intent it shall start the debugger and stop in the Log line so you can continue debugging.