The push registry enables MIDlets to set themselves up to be launched automatically, by setting an alarm or by sending data over the network. The push registry manages network- and timer-initiated MIDlet activation; that is, it enables an inbound network connection or a timer-based alarm to wake a MIDlet up. For example, you can write a workgroup application that employs network activation to wake up and process newly received email, or new appointments that have been scheduled. Or you can use timer-based activation to schedule your MIDlet to synchronize with a server every so often then go to sleep.
This is a general property of MIDP2.0 specification.But different vendors have implemented it differently. For eg; in Nokia & Sonyericsson phones there a permission message is displayed whether you want to activate the push registered application. Where as in Siemens phones only a star sign will be displayed.
The PushRegistry class exposes the following methods:
- getFilter(), to return the <AllowedSender> value for the connection (this can be
a server IP address, a comma-delimited list of IP addresses, or an * to allow any connection).
- getMidlet(), to return the MIDlet name registered for the specified connection.
- listConnections(), to return a list of push connections registered for the specified
- registerAlarm(), to register a timer-based trigger to launch the MIDlet, or to
disable an existing alarm for the MIDlet if the argument supplied is zero.
- registerConnection(), which registers a connection for the MIDlet.
- unregisterConnection(), which likewise unregisters a connection.
The following exceptions should be caught:
Using SMS Connections
It is useful to note that a MIDlet can initiate a socket or HTTP connection after it has been awakened by an incoming message, if further exchange of data is required.
The port specified can be from the full range 1 to 65535, however the following ports are reserved and must not be used:
- 2805 WAP WTA secure connectionless session service
- 2923 WAP WTA secure session service
- 2948 WAP Push connectionless session service (client side)
- 2949 WAP Push secure connectionless session service (client side)
- 5502 Service Card Reader
- 5503 Internet access configuration reader
- 5508 Dynamic Menu Control Protocol
- 5511 Message Access Protocol
- 5512 Simple e-mail Notification
- 9200 WAP connectionless session service
- 9201 WAP session service
- 9202 WAP secure connectionless session service
- 9203 WAP secure session service
- 9207 WAP vCal Secure
- 49996 SyncML OTA configuration
- 49999 WAP OTA configuration
Push Registry can handle requests to register connections in two ways:
- dynamically at run time,
- statically through entries in the JAD file
Dynamic registration is a MIDlet notifying the AMS at run time that it wants to be activated by an incoming network connection or alarm event should the MIDlet be exited prior to that event occurring.
For a connection the registerConnection method is used:
can be used to specify the current MIDlet.
Some of the examples for Dynamic Registration :
registerConnection(“sms://:” + portNumber);
registerConnection(“datagram://:” + portNumber);
If a connections sender and connection type are known when the MIDlet is installed, the registration request can be made at installation, and is therefore regarded as static. Static requests are defined in the JAD file using the Midlet-Push-<n> attribute:
MIDlet-Push-<n>: <ConnectionURL>, <MIDletClassName>,
where n is a sequence number allowing more than one connection to be declared, ConnectionURL is the URL to monitor for an incoming connection, MIDletClassName is the MIDlet to start, and AllowedSender is the filter: a list of IP addresses or * for any.
An example for SMS connection :
MIDlet-Push-1: sms://:10000, TestMIDlet, *
Unregistering the connections
Dynamic registrations can be removed by using unregisterConnection specifying the connection only:
To determine if the MIDlet was invoked by an incoming message:
connectsFound = PushRegistry.listConnections(true);
This returns the list of registered connections.
if connectsFound == null || connectsFound.length == 0)
~ started by user, code to exit or bypass push-related activity ~
~ started by inbound connection so code for push registry initiation ~
Sun Resourece: http://developers.sun.com/mobility/midp/articles/pushreg/
java world resoure: http://www.javaworld.com/javaworld/jw-04-2006/jw-0417-push.html
Sonyericsson resource: http://developer.sonyericsson.com/wportal/devworld/page-not-found?cc=gb&lc=en