Mastering Android Widget Development - Part3

SDK Version: 

I just come to a new discovery regarding widgets. I was developing an appwidget, which - just like the widgets we are trying to make in this series of tutorials - and tried it out multiple phones. Unfortunatelly on one of our test phones it didn't function properly. For random intervals it stopped to refresh, and it din't responded to button presses on the widget, only after 1-2 minutes. After hard work I discivered the following:

Buttons on appwiget can have their onclick flunctionality thorough RemoteViews.setOnClickPendingIntent(). This method gets a PendingIntent ap parametes to bound to a button. PendingIntent's can have 3 types created with

getActivity(Context, int, Intent, int)

getBroadcast(Context, int, Intent, int)

and getService(Context, int, Intent, int).

Mastering Android Widget Development - Part2

SDK Version: 

In Mastering Android Widget Development - Part1 we have gone trough the basics of appwidgets. Now we start to develop the example application, which couts time left to a given date.

First implement the configuration activity. It will contain a DatePicker, an OK button and a Cancel button, defined in the configuration.xml layout:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3.   xmlns:android=""
  4.   android:layout_width="wrap_content"
  5.   android:layout_height="wrap_content"
  6.   android:orientation="vertical">
  7.         <DatePicker android:layout_width="wrap_content"
  8.         android:layout_height="wrap_content"
  9.         android:id="@+id/DatePicker">
  10.         </DatePicker>
  12.         <LinearLayout
  13.         android:id="@+id/LinearLayout01";
  14.         android:layout_width="wrap_content"
  15.         android:layout_height="wrap_content"
  16.         android:orientation="horizontal">

Mastering Android Widget Development - Part1

SDK Version: 

In Days to Xmas tutorial you can see a simple widget example, which demonstrates what widgets are used for, and shows an example how they can work. Now I begin a series of tutorials to fully explain the working of widgets.
We will also create a sample application, during the tutorials, which will show a countdown to a given date in secunds, but things that are not required for this specific example applications will be explained too.

For this first part I will go though mainly the parts described in but I try to give more explanation and advice.

Some general thoughts at first:

MusicDroid - Audio Player Part III

SDK Version: 

I part 3 of the MusicDroid tutorial we create a simple controls interface that will be launched by our playlist when you play a song. The controls interface is a translucent Activity that simply has 4 images, one for each direction on the D-Pad. When you hit a direction on the pad it will send a command to the service and play a small animation.

This tutorial utilizes the work done in parts 1 and 2, though you do not have to be familiar with those parts if you just want some examples of animation or transparency.

Syndicate content