Tuesday, December 30, 2014

Spread : AppWidget


Here is a VERY simple representation of our AppWidget class inherited from AppWidgetProvider.

A widget is (by default) owned by the home screen app meaning that the methods listed above will be called by the home screen.

onEnabled: called when the first instance of the widget is created
onDisabled: called when the last instance of the widget is deleted
onDeleted: should be called when an instance of widget is deleted from home screen but a known issue exists. This method does not seem to be called properly.
onUpdate: called regularly by the home screen (period is configurable in xml info file)
onReceive: Intent listener (see below)


At first, I was lost with this object as I was looking for a way to add a click listener for a button. Well, unlike an Activity, you will have to deal with Intents here.
An Intent can be seen as a mail that can be sent to one or many objects throughout the system (broadcast). We will detail them in a further post.

So here is how the widget will interact with other activities:


Post a Comment

Note: Only a member of this blog may post a comment.