MIDP 2.0 compliant devices implement a push registry that allows inactive MIDlets to be launched in response to external events, such as received SMS messages, or previously set timers. With Push, MIDlets can in a sense be run like services on a mobile device to handle certain tasks without the user's explicit interaction. While the MIDlet is active, the MIDlet itself is responsible for dealing with any push events that may occur. The AMS does not get involved at that point.
When the AMS detects an incoming connection or an alarm based activation
associated with a MIDlet, the AMS starts the MIDlet and calls the startApp()
method.
At this point the MIDlet takes over responsibility for the connection and
performs the steps necessary for handling the incoming connection.
Method |
Description |
---|---|
|
Returns the |
|
Returns the Midlet responsible for handling the specified push connection. |
|
Returns the list of registered push connections for the Midlet suite. |
|
Registers a timer-based alarm to launch the Midlet. Disables alarms if it is set to zero. |
|
Registers a push connection. |
|
Unregisters a push connection. |
The push connections in a MIDlet can be registered in two ways, statically and dynamically:.
Static
If a connection's sender and connection type are known when the MIDlet
is installed, a connection can be registered by a connection string in the
application's JAD or
manifest file using the element MIDlet-Push-[number]
.
Syntax: MIDlet-Push-[number]: ConnectionURL, MIDletClassName,
AllowedSender
Example: MIDlet-Push-1: socket://:7224, PushExample,
200.20.20.1
The JAD or manifest file has no upper limit on the amount of Push connections. The MIDlet starts listening to the connections registered in this manner as soon as the MIDlet is activated and stops only after the mobile device has been rebooted or the MIDlet uninstalled.
Dynamic
In dynamic registration, a MIDlet notifies the AMS that it needs to
be activated by an incoming network connection or an alarm event if the MIDlet
has been exited prior to that event. A dynamic connection is registered using
the registerConnection()
method at runtime.
Syntax: registerConnection(String connection, String
midlet, String filter)
Example: PushRegistry.registerConnection("socket://:7000",
"PushMIDlet", "*")
All push connection parameters can be replaced with a wildcard *
,
although their excessive usage should be avoided. Several MIDlets can also
have Push connections registered at the same time.
For more information on Push registration, see PushRegistry specification.