For most new android app developers (like me), it is a bit puzzling how to debug the android widgets or how to put a breakpoint in an android widget code. For normal applications, it is quite simple as when you press “debug” on the eclipse toolbar, it launches the emulator (or connects to existing emulator/device), syncs your application and launches its main activity and puts the control in your hands if you have put a breakpoint. For widgets, it seems a bit tricky because there is no activity to be launched, so eclipse just syncs your widget’s apk and installs it and that’s it. So, is it possible or not to debug widget code? and if yes, then is it very difficult? Fortunately, it is possible and very easy to do but just slightly less intuitive and I couldn’t find any information about it at Android developers website and learnt it by just fumbling around for a few minutes so thought of posting here for the benefit of other newbies like me.
So, all you need to debug your widget code is almost same as what you do for normal applications. Just follow the below steps:
1. Press “debug” on the eclipse menu (or “run” it doesn’t seem to matter)
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. 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. Press the green debug button above the process list (See screenshot below)
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-Widgets-Spinners
NULL 博文链接:https://ouyangfeng521.iteye.com/blog/1067376
android-misc-widgets.rar
Android 电量显示Widgets,可以显示当前的系统的电量。
Android, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers...
包含多种特效,尤其是动画。 很不错的学习源码
最近学习的android新建桌面widgets,附有源码,可以看一下
Android, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers...
Pro Android 4 shows you how to build real-world and fun mobile apps using the new Android SDK 4 (Ice Cream Sandwich), which unifies Gingerbread for smartphones, Honeycomb for tablets and augments ...
Android-Widgets-Buttons.
Pro Android 5 shows you how to build real-world and fun mobile apps using the Android 5 SDK. This book updates the best-selling Pro Android and covers everything from the fundamentals of building apps...
To start, it shows how to use the Eclipse IDE to code, test, and debug a Tip Calculator app for a smartphone or tablet. Then, it expands upon this app to show must-have Android skills such as working ...
Pro Android 5 shows you how to build real-world and fun mobile apps using the Android 5 SDK. This book updates the best-selling Pro Android and covers everything from the fundamentals of building apps...
安卓Android源码——电量显示Widgets插件实现.zip
Android is a software toolkit for mobile phones, created by Google and ... In addition, two new appendixes show you how to create Widgets for the Home screen and publish your application to the Android
Creating Flash Widgets with Flash CS4 and ActionScript 3.0 targets novice to intermediate Flash designers/developers interested in learning how to create and publish widgets for the Internet.
Android Programming Tutorials gives you hands-on instruction in how to build sophisticated Android applications, using many of the technologies outlined in CommonsWare’s other Android books....
Android 电量显示Widgets插件源码.rar
mobyfactory-uiwidgets-android mobyfactory-uiwidgets-android