Challenges with App Widgets

Historically, relatively few apps publish app widgets. While app widgets are reasonably popular among “power users”, but they are not easy to discover. As noted above, iOS adding an equivalent capability will help drive user interest, and that in turn is likely to drive developer interest.

However, there is another reason why relatively few apps publish app widgets: developing app widgets is seriously weird.

Somebody Else Draws the UI

Android app developers are used to drawing the app’s UI themselves, typically in the form of widgets in activities and fragments as we have seen here in this book.

App widgets use the same sort of View and ViewGroup subclasses that we use for activities and fragments, with a lot of limitations. However, our apps do not actually draw those widgets. Instead, the home screen does. We tell the home screen “please have my app widget contain X”, and the home screen is responsible for actually doing the work.

Inter-Process Communication

To make that possible, we have to arrange to get our requested app widget UI over to the home screen for rendering. Since the home screen is part of the launcher app, it runs in a completely separate OS process from our own. So, our process needs to tell that other process what to do, and this makes things cumbersome.

Part of the problem is that for such inter-process communications to work, both sides have to agree on how to send and receive information. That makes changes to the communications protocol challenging: if one side sends something that the other side does not understand, then something may go wrong with the app widget.

Lots of Tumbleweeds

That protocol problem means that Google has not changed how app widgets work very much over the years. App widgets were introduced in Android 1.5, back when dinosaurs roamed the Earth.

(OK, perhaps not that long ago, but quite a while)

While app widgets got one round of improvements in Android 3.0 and a few minor tweaks since then, app widgets are still largely stuck with a protocol that is over a decade old.

Plus, because both sides have to agree on the protocol, we cannot use things like RecyclerView — while our app might have that, the launcher app might not.

As a result, app widgets have a very limited roster of available View subclasses that you can use, and some of those subclasses are ones that you would not use normally because they have been replaced by newer alternatives.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.