The configuration bug

Fork me on GitHub

If you create a widget with a configuration activity, you may get a strange bug that involves unexpected creations of instances.
Read more of this post


Take your time – Widgets and AlarmManager

Fork me on GitHub

In our previous example, our widget is updated through two events: user’s tap and the updatePeriodMillis of the provider info file.
Using the xml file has two main disadvantages:

  1. Users cannot select the update interval.
  2. The minimum interval time is 30 minutes.

To overcome these problems, just use an AlarmManager to fire the updates.
Read more of this post

One update for widget

Fork me on GitHub

With the widget of my previous post, if we add more than one widget to our home screen and tap to one of them, all the widgets, all the instances, update themselves.
Also, when we tap “Ok” at the configuration Activity, all the widgets update, again.

This may be the exact behavior we wanted but what if we desire that only one instance, among multiple instances, updates at the click event and after a successful configuration?
Read more of this post

Android App Widgets and their Configuration

Fork me on GitHub

Recently, I tried to implement an Android App Widget with a Configuration Activity.

It didn’t went smoothly but I did learn something on the way.
I will expose what I could learn this time in three four posts: this first one with the bare minimum to make a working widget + configuration, a second one where I’ll describe my attempt to direct a click event to only one instance among several instances of the same widget, a second third one with an AlarmManager that trigs the updates and a third fourth and last one in which I will expose a known bug and my attempt to solve it.

The theory

An Android App Widget may have a Configuration Activity that launches when the user add the widget on the Home Screen. It is used to let the user customize some settings of the impending widget, like the color or what data to show.
It is not mandatory but it may comes in handy in many use cases.
Read more of this post