问题描述
对于正常的Activity,我可以设置一些断点,然后在Eclipse中单击F11进行调试.但是,当我开发应用程序小部件时,它不起作用.那么,我该如何调试?
For normal Activity, I can set some breakpoints and click F11 in Eclipse to debug.However, it is not working when I develop app widget. So, how can I debug?
推荐答案
在这里,您可以找到一个很好的答案:
Here you can find a good answer:
调试小部件代码所需的一切几乎与对普通应用程序所做的相同.只需执行以下步骤:
All you need to debug your widget code is almost same as what you do for normal applications. Just follow the below steps:
1..在日食菜单上按调试"(或运行"似乎无关紧要)
1. Press "debug" on the eclipse menu (or "run" it doesn’t seem to matter)
2..在同步小部件apk并将其安装到模拟器/设备上后,将您的日食工作区切换为DDMS模式.您可以通过按右上角标记为"DDMS"的按钮来执行此操作,或者,如果找不到它,则可以转到窗口"->打开透视图"->"DDMS".
2. Once the widget apk is sync’ed and installed onto your emulator/device, switch your eclipse workspace to DDMS mode. You can either do this by pressing the "DDMS" labeled button on your top right corner or if you can’t find it, then do it by going to "Window->Open Perspective->DDMS".
3..从显示的进程列表中选择窗口小部件的进程名称.默认情况下,此列表显示在DDMS窗口的左上方. (请参见下面的屏幕截图).如果您在列表中看不到小部件的进程名称,则可能是该小部件尚未添加到主屏幕.所以,这样做.
3. Select the process name of your widget from the list of processes shown. By default, this list appears at top left of DDMS window. (See screenshot below). If you can’t see your widget’s process name in the list, it is possible that the widget is not added to the home screen yet. So, do so.
4..按下进程列表上方的绿色调试按钮(请参见下面的屏幕截图)
4. Press the green debug button above the process list (See screenshot below)
5.就是这样.现在,如果您在代码中添加了一个断点,请执行一些可以执行该代码段的操作.
5. And that’s it. Now, if you had put a breakpoint in the code, do something that executes that piece of the code.
这篇关于如何使用Android App Widget进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!