//Registers the pushRegistry
public void Register(){
// List of registered push connections.
String connections[];
// Check to see if the connection has been registered.
// This is a dynamic connection allocated on first
// time execution of this MIDlet.
connections = PushRegistry.listConnections(false);
if (connections.length == 0) {
try {
//Register so the MIDlet will wake up when phone is started.
PushRegistry.registerConnection("autostart://:",
"AutoStartDyn", "*");
sDisplayString = "MIDlet is registered";
} catch (Exception ex) {
System.out.println("Exception: " + ex);
sDisplayString = "Fail: " + ex;
}
} else {
sDisplayString = "Already registered";
}
displayForm.deleteAll();
displayForm.append(sDisplayString);
}
//Unregisters the pushRegistry
public void Unregister(){
if (PushRegistry.unregisterConnection("autostart://:")){
System.out.println("The pushRegistry is unregistered");
sDisplayString = "MIDlet is unregistered.";
}else{
System.out.println("There is no pushRegistry to unregister");
sDisplayString = "No MIDlet to unregister or failed to unregister";
}
displayForm.deleteAll();
displayForm.append(sDisplayString);
}