Asynchronous Processing in Java ME: The Push Registry

When writing mobile applications, you may encounter situations where you need to execute logic independently of user interaction. For example, your application may need to do something in response to an outside event, such as an e-mail message being received. You could put a loop in your application that periodically checks to see if the conditions for performing the task have been met. However, even if it were supported by the device, this approach could consume valuable resources. A better solution is to use the push registry API, which was added in MIDP 2.0. In this article we will take a look at the features and limitations of the push registry.

The push registry allows your application to request that the device launch a MIDlet asynchronously. This ability can be incredibly useful for many types integration. There are two types of push events: push connections and push alarms. A push connection is triggered in response to an inbound network connection. A push alarm, on the other hand, is triggered by a timer and can be used run some code on a regular interval, for example.

There are two ways to register a push event. Push connections and push alarms can be registered using the PushRegistry API, found in the javax.microedition.io.PushRegistry class. In addition, push connections can be defined in the JAD file or JAR manifest.

The PushRegistry API has a number of limits. First, when using connection events, only one application can be registered on a given port at a time. This means that your application should probably be designed to handle conflicts at port-level. Second, both push and network operations are considered restricted operations in MIDP 2.0. This means that your application must explicitly request push and network permissions in the JAD file or JAR manifest. In addition, your code will probably need to be signed in order for it to be granted those permissions on most devices.

For more detailed information about the PushRegistry, be sure to check out the following links:

Bookmark this article: del.icio.us Digg Furl Reddit blogmarks Google Spurl StumbleUpon Technorati Yahoo!

Tags: , , , , , , ,

Leave a Reply

You must be logged in to post a comment.