为 Android 开发时,如何在 AsyncTask 中使用 Eclipse 调试器? [英] How do I use the Eclipse debugger in an AsyncTask when developing for Android?
问题描述
我在 Eclipse 中运行 ADT(Android 开发工具)并通过在 MainMenu.oncreate(类活动)
中放置断点来验证我的调试器是否正常工作.但是当我把它放在我的 AsyncTask.doInBackground
的第一行时,它永远不会命中它.我知道它正在运行,因为我在 AsyncTask
中放置了一个 Log 语句,它显示在 LogCat 中.任何帮助将不胜感激,因为我更喜欢调试器而不是日志记录.
I'm running ADT (Android Development Tools) in Eclipse and verified that my debugger is working by putting a breakpoint in MainMenu.oncreate (class Activity)
. But when I put it in the first line of my AsyncTask.doInBackground
, it never hits it. I know it's running because I put a Log statement in the AsyncTask
and it shows up in LogCat. Any help would be appreciated as I prefer the debugger over the logging.
我的版本:
Eclipse SDK Version: 3.6.1
Build id: M20100909-0800
推荐答案
将以下代码片段放在doInBackground
的开头:
Put the following code fragment in the beginning of doInBackground
:
android.os.Debug.waitForDebugger();
然后当您在该线程中设置断点时,eclipse 会找到它.
Then when you set a breakpoint in that thread, eclipse will find it.
这篇关于为 Android 开发时,如何在 AsyncTask 中使用 Eclipse 调试器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!