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是应用程序提供的一种交互式小部件,它们可以在用户的主屏幕上显示,为用户提供快速访问或控制应用功能的方式。这些小部件是Android SDK的一部分,允许开发者创建自定义的桌面组件,提升...
### Android Widgets: Spinners 在Android开发中,Spinners(也称为组合框或下拉列表)是一种常用的用户界面组件,用于展示一系列可选择的项。本文将深入探讨Spinners的基本概念、实现方式以及如何在实际项目中应用...
"Android Misc Widgets" 是一个专为Android平台设计的开源项目,其主要目的是提供一系列具有特殊效果和动画的组件,供开发者学习和参考。这个项目的源码涵盖了多种Android小部件的实现,是Android开发者提升技能、...
在Android开发中,桌面Widgets是用户界面的一种扩展,允许应用程序在主屏幕上提供快捷方式或实时信息,无需打开应用即可与之交互。以下是对"android新建桌面widgets"这一主题的详细阐述: 1. **Android Widgets概述...
"android-misc-widgets.rar"这个压缩包中,很可能包含了多种不同类型的Android小部件示例,用于展示和学习如何在实际项目中创建和定制各种小部件。下面我们将详细探讨Android小部件的相关知识点。 1. **小部件基础...
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电量显示Widget,包括必要的技术知识点和源码解析。 首先,我们需要...
在安卓平台上,开发一款电量显示Widgets插件涉及到多个关键知识点,包括Android SDK的使用、Widget API的掌握、UI设计以及电源管理API的应用。下面将详细解释这些知识点。 1. **Android SDK**: 安卓应用程序的基础...
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系统架构、Widget API、电量监控机制、UI设计以及性能优化等。下面将详细阐述这些内容。 1. **Android系统架构**: Android系统由...
在Android系统中,Widgets是应用程序提供给用户的一种交互方式,让用户可以在主屏幕上快速访问或控制应用功能,而“Android源码——电量显示Widgets插件源码”则是一个专门用来显示设备电量信息的小部件。...
### Android Widgets: Buttons及相关可点击控件 #### 概述 在Android开发中,`Button`及相关的可点击控件是用户界面设计中不可或缺的一部分。这些控件允许用户通过触摸屏幕来触发应用程序中的某些动作或功能。本篇...
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 ...
在Android平台上,电量显示Widgets是用户界面中一种实用的功能,它允许用户在主屏幕上快速查看设备的当前电量状态,而无需打开设置应用或通过通知栏查看。"Android 电量显示Widgets插件源码.rar" 提供了实现此类功能...
A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box. Snake An implementation of the classic game "Snake." Soft ...
在Android平台上,Widgets是应用程序提供的一种功能,它们可以在用户的主屏幕上显示实时信息,如天气、新闻、音乐控制或,如本例所示,电池状态。这个"Android 电量显示Widgets插件源码.zip"是一个用于创建自定义...
在安卓平台上,开发一款电量显示Widgets插件涉及到多个关键知识点,包括Android SDK的使用、Widget组件的实现、电源管理API的交互以及UI设计等。以下将详细解释这些方面。 首先,Android SDK是开发者构建Android...