Application Trigger messages are SMS messages that target a specific port number on a mobile phone. These messages can be used to execute applications or perform actions within applications, without explicit user input. This article focuses on one of the main uses of this message, the ability to interact with the J2ME Push Registry in order to load or execute code within a Java MIDlet
The Push Registry is essentially a lookup table within the Java Application Managment System (AMS) on a mobile device. A MIDlet supporting this functionality can add an entry to this registry either at install time or during the application runtime. This entry includes the name of the MIDlet as well as an assigned port number. When the MIDlet is not active, the Push Registry handles any push events that occur by activating the appropriate MIDlet to handle them. The Push Registry knows which MIDlet to activate as each MIDlet has to be registered on a different port. If the application is already active then the MIDlet is left to handle the event. The easiest way to register a port for a MIDlet is to do it statically by defining all the attributes in the JAD. This tutorial demonstrates how to register a MIDlet on the Push Registry statically.
There are severals ways to interact with the Push Registry, including triggers based on timers and incoming Bluetooth connections This article focuses on the use of SMS messages as the trigger mechanism. The following diagrams illustrates how the Push Registry fits in with the lifecycle of a MIDlet:

The Wireless toolkit provides a good place to start when being introduced to the idea of Application Trigger messages. It allows an easy process to specify the static properties to register your MIDlet. To use the WTK it is necessary to download and install it, this also downloads a number of example applications that are useful to run.
http://java.sun.com/products/sjwtoolkit/
Netbeans comes with a mobility pack add on, this can also be used to develop MIDlets using the Application Trigger mechanism. Netbeans is useful when developing the MIDlet as its offers a drag and drop interface to create the MIDlet interface . Developing this way does then limit the amount of code writing that can be done. It is also possible to write all the code yourself using Netbeans if you don't use the visual drag and drop process.
Eclipse also offers a J2ME development add on called EclipseME. To use EclipseME you need to download Eclipse IDE and an emulator such as the Wireless Toolkit. Once these are installed follow these instructions on how to install EclipseME.
http://eclipseme.org/docs/installEclipseME.html

For more information on Application Trigger messages have a look at the following links:
The first step to creating an Application Trigger is to set up the MIDlet so it will be registered successfully with the Push Registry
To create a MIDlet that uses the Push Registry you will need to download the most up to date version Java 2 Platform, Standard Edition (J2SE) and the Java Wireless Toolkit or Netbeans along with the mobility pack.
The first step is to define the attributes for the Push Registry:
Select the User Defined section. This allows you to define the properties of your application that can later be used in your development. This allows you to define your SMS port number within the properties of the application rather than having to hard code it, and then retreive the SMS port using the method below. This means to change the port you only have to change it in one place, allowing easy maintenance.
This code shows how the SMS port can be retrieved from the applications properties.
public SMSReceive() {
smsPort = getAppProperty("SMS-Port");
//...
}
Within the MIDlet section it is necessary to define the details about the MIDlet you are creating i.e. the Name, any Icon you want for it, and where the class is found. If you are not defining any packages then the class is just the name of your file. When you created the new project these details where filled in so edit them as necessary.
It is now necessary to set the permissions for the MIDlet. Select the permissions by selecting the permissions icon and add the following using the tree structure:
javax/microedition/io/Connector/sms
javax/wireless/messaging/sms/receive
javax/microedition/io/PushRegistry
Once your application is created and transfered to a mobile device it will be registered on port 6666.
The first step is to define the attributes for the Push Registry:
Select the Application Descriptor section. This section allows you to define the properties of your application that can later be used in your development. For example you can define your SMS port to be used in this section and then within your code request the port number. This code shows how the SMS port can be retrieved from the applications properties.
public SMSReceive() {
smsPort = getAppProperty("SMS-Port");
//...
}
Within the MIDlets section it is necessary to define the details about the MIDlet you are creating i.e. the Name, any Icon you want for it, and where the class is found. If you are not defining any packages then the class is just the name of your file. When you created the new project these details where filled in so edit them as necessary.
It is now necessary to set the permissions for the MIDlet. Select the API permissions tab then add the following permissions by clicking the add button and then entering the following.
javax.microedition.io.Connector.sms
javax.wireless.messaging.sms.receive
javax.microedition.io.PushRegistry
After further development it may be necessary to add more permissions, these defined permissions just allow the application trigger mechanism to work.
Once your application is created and transfered to a mobile device it will be registered on port 6666.
A MIDlet activated by an Application Trigger message will have to handle incoming messages so you will need to import the javax.wireless.messaging library. Any application to be triggered by an SMS message will need to implement the MessageListener interface and perform an action when this receives a message.
public class SMSReceive extends MIDlet
implements CommandListener, Runnable, MessageListener {
//......
}
Below I have listed all the methods I feel are important with the handling of the SMS messages and their content. It is important to have a method that runs when a message is received. This method below creates and starts a new thread to run the application or it could be edited to perform an action if the application is already running when the message is received..
public void notifyIncomingMessage(MessageConnection conn) {
if (thread == null) {
done = false;
thread = new Thread(this);
thread.start();
}
}
As you are creating a MIDlet it is necessary to create the startApp method that runs when you choose to run the application.
This will need to perform similar actions to the above method except it will need to create the message connection.The smsPort is obtained from the MIDlets properties as shown in the above section about registering the MIDlet.
public void startApp() {
String smsConnection = "sms://:" + smsPort;
if (smsconn == null) {
try {
smsconn = (MessageConnection) Connector.open(smsConnection);
smsconn.setMessageListener(this);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
//...
}
Once a message has been received by an application it is useful to be able to retrieve the contents of the message. This can be done simply using the method below..
public String receiveMessage(){
try{
senderAddress = msg.getAddress();
myString = ((TextMessage)msg).getPayloadText();
return myString;
} catch(Exception e) {System.out.println("nothing received");}
return null;
}
To view the complete source code for an Application Trigger MIDlet refer to http://www.javaworld.com/javaworld/jw-04-2006/jw-0417-push.html?page=2#resources