Skip to content

From the Developer’s Kitchen: Widgets

March 18, 2010

From the Developer’s Kitchen is a segment where we channel thoughts and ideas from our developers as they go about their daily business. Our first post is about implementing widgets in Android. Widgets reside on a home screen on your Android phone and allow instant access to information or functions without having to open a separate app.

Widgets are very memory and resource intensive. This is because they are nothing more than “Remote Views” that display data from an external source (external to the app; could be a database in the phone or weather data from an internet stream). Every time the data updates and/or the view is scheduled to update (the is specified in the app manifest in milliseconds), the entire widget is redrawn on the home screen.

With widgets such as Facebook that have to update frequently to keep up with everyone’s updates, you can easily see how the system gets bogged down and battery life goes to hell. With the current notes widget we are developing, the refresh time is set to 0 milliseconds which means it will never refresh on its own. The refresh in this case is event-driven and only happens in response to an action by the user. The notes themselves will never be edited outside of the app, so there is no need for a regular interval of refreshes to stay up to date.

In future widgets which may draw on external data, we have some great ideas on how we will keep battery usage to a minimum, such as incorporating an activate-on-view feature or allowing users to set intervals.

Because a widget is simply a view, you cannot enter text data into it… well, you can set up a text box to receive user input, but there’s no way to programmatically grab the text and do anything meaningful with it.

The way the Google search and Facebook widgets have gotten around this is to simply make their text boxes shortcuts to a lightweight app that doesn’t fill the whole screen (dialog box)…the process is virtually seamless to the user.

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: