Nov 15, 2009

New MIDlets: Screen Saver

Hi all,

A MIDlet, as we know today, is an application model defined by Mobile Information Device Profile (MIDP) that allow us to create resource limited applications. A MIDlet merely consists of a class that extends the javax.microedition.midlet.MIDlet class. Until MIDP 2.1, MIDlets have been developed to work as entertainment or business applications, for instance. In other words, they have been developed to aggregate some value to the devices. From MIDP 3.0 this story is about to change.

MIDP 3.0 brings new types of MIDlet that will allow developers to create applications that can work as device's feature and not just as a single application. These new types are:
  • Screen Savers
  • Idle Screen
In this post, we will focus on screen saver MIDlet. Let's talk about idle screen MIDlets in a next post.

A screen saver MIDlet is an application that can be launched automatically when the device enters in the idle state, in other words, after a certain period of inactivity. For instance, no call ongoing and the user has not pressed any keys. As soon as a screen saver MIDlet is launched, it keeps running until it is deactivated by an external event or user action, e.g., by pressing any key.

The structure of a screen saver MIDlet is same as any ordinary MIDlet. The only difference is in JAD/JAR files. To set a MIDlet as a screen saver, the entry “MIDlet--Type: screensaver” must be defined. The rest is just the same as you are already used to.

MIDlet-1: Clock3DSaver, /icon.png, ClockScreenSaverMIDlet
MIDlet-1-Type: screensaver

The way the user will set a given MIDlet as the current screen saver is totally up to the platform. I believe it is not a big deal. The manufactures must just add the MIDlet names in the current screen savers list already available in the devices.

To identify whether a screen saver MIDlet is the current selected one, the method MIDlet.isSelectedScreenSaver() was created to answer this question. Naturally, if the MIDlet is not a screen saver, this method will return false.

MIDP 3.0 brings a new feature, which is a mechanism for notifying an application of changes in the system state and for an applications communicate to each other (we will talk more about it in the next posts). In the context of screen saver MIDlet, this event notification works to inform the screen saver if it was activated or deactivated. For that, the MIDlet must implement the interface EventDataListener and then registers itself through the method DataManager.addEventListener. From this moment on, the MIDlet just needs to handle the EventData.SCREENSAVER_MODE event (SCREENSAVER_MODE_ACTIVATED or SCREENSAVER_MODE_DEACTIVATED). For instance, to deactivate a screen saver MIDlet, the device can decide to use any key to perform this task. In addition, an incoming call can also force a screen saver to be deactivated.

I liked this new possibility, because it gives to us more power to create applications that can really customize our devices. Sony Ericsson, for instance, since its JP7 platform, already allows that a MIDlet can be set as wallpaper. Now, for more details, consult the MIDP 3.0 specification.

See you in the next post…

No comments: