Getting started with Android can seem a slow process, particularly for developers who don’t come from a Java background. In this detailed HTML text tutorial, we take you through each step in the task of creating a battery level widget app. As well as learning how to create a widget app for the Android platform, you will learn how to update the widget using system data. The widget includes a textual and visual indicator of the current battery level on the user device.
The end result of this tutorial is a fully functioning Android widget app, and the focus throughout is on equipping you with practical skills you will be able to draw on into the future.
The tutorial works through each step in turn, with annotated code excerpts and plenty of informative images indicating key phases of the process in Eclipse. The source code (both XML and Java) is provided with additional notes and within the directory structure for the finished app.
Skills covered within the tutorial include: using receivers in widget apps; handling the manifest and application resources for an Android widget (including colors, layouts, drawables and XML data); using various Java language structures and techniques, including inheritance, conditionals, methods and instance variables.
We will work through the task of creating the battery level widget app in detail. I believe that the best way to learn programming skills is by implementing them yourself. However, it is also vital to understand what you are doing at each stage, rather than simply copying the code into your own project. For these reasons we work through the steps at a relaxed pace, and if you want to stop and go back over any of them you are free to do so.
The tutorial contains the following steps:
Create a New Android Project
Edit your Project Manifest
Create the Widget Metadata
Create the Widget Layout
Create the Widget Drawables
Define the Widget Colors
Implement a Java Class to Handle Widget Updates
This tutorial is accessible to anyone who has attempted at least one Android development project already, even a basic/ introductory app. As long as you have basic programming skills you should be able to work through the steps. How long the tutorial will take you to complete really depends on your experience level. If you already have significant Android experience you could do it in a couple of hours, but if you’re new to the platform it may take several hours. If you are a beginner I recommend taking your time and making sure you take in each technique – this way you are learning new skills rather than just getting the job done.
I work as a developer and technical writer, having originally come from a Java development background following my Masters degree in Information Technology. I’ve worked as a tutor for students learning computer programming topics so am accustomed to taking learners from beginner to intermediate/ advanced in a relatively short period of time. I particularly enjoy writing on Android development as I believe the techniques are accessible to people from a variety of backgrounds, but who are deterred by a lack of suitable learning materials.
Hope you enjoy the tutorial.
Download Jump Into Android: Create A Battery Level Widget (Fundamentals)