Demo Title: MIDP 2.0 Push Functionalty & Wireless Messaging API (WMA) Demo Developer: Srikanth Raju Technology used: MIDP 2.0, J2ME Wireless Toolkit 2.0 - Beta 2, Wireless Messaging APIs (WMA) Background: MIDP 2.0 introduces a key new feature - the Push. Push Functionality enables a MIDlet to be launched asynchronously as a result of an incoming Network Connection or a Timer. The Wireless Messaging APIs (WMA) enables MIDlets to send and Receive SMS/CBS Messages. Demo Goal: This Demo Demonstrates how to write a MIDlet that uses the Push Functionality, i.e. launching a MIDlet automatically when a network notification happens. The specific Network Connection illustrated in this example is an incoming SMSConnection. This demo also illustrates the steps and sequence that need to be followed prior to and during the installation and invocation of the Push MIDlet. The steps involved are as follows: 1) Write the source code for the MIDlet that will be launched when there is an incoming SMS Connection. 2) Specify the Push attributes in the Wireless Toolkit 3) Install a regular MIDlet via OTA 4) Install the PushMIDlet via OTA, thereby informing the Phone/emulator the Push attributes. 5) Run the Regular MIDlet 6) Send an SMS Message to the emulator/phone running the regular MIDlets 7) Notice that the MIDlet specified in Step 2 is launched. What a developer will learn by running this demo is: In this Demo, the user will learn how to register the Push attributes in the Descriptor File (JAD), and how to cause the Push Notifications. In addition, the developer will also learn how to receive SMS messages and respond to it (by launching a MIDlet when there is an incoming SMS message) System requirements: - Solaris, Linux or Windows - J2ME Wireless Toolkit 2.0 Beta 2 Deliverables: - Source files - Documentation Instructions to Build and Run this demo: ======================================== 0. Make sure you download the J2ME Wireless Toolkit Beta 2. You should also make sure that you have the Wireless Toolkit (WTK) Beta 2. Let us call the directory where WTK is installed as WTK_HOME . 1. Unzip the SMSPushDemo.zip file in the directory . This will create a folder called SMSPushDemo in the apps directory. 2. In the WTK, click on the Settings Button. Select the "Push Registry" tab. Make sure that the following entry is there: MIDlet-Push-1 : sms://:50000, SMSPushDemo, * 3. Launch WTK. Select Open Project | SMSPushDemo | Build . This will Build the Project. 4. Select Project | Package | Create Package 5. Notice that the SMSPushDemo/bin directory now contains a SMSPushDemo.jad that looks like the following: MIDlet-1: SMSPushDemo, , SMSPushDemo MIDlet-Jar-Size: 2224 MIDlet-Jar-URL: SMSPushDemo.jar MIDlet-Name: SMSPushDemo MIDlet-Push-1: sms://:50000, SMSPushDemo, * MIDlet-Vendor: Sun Microsystems MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-2.0 Installing the Push MIDlets =========================== 6. Registration for Push happens during Install time. Hence, you must always "Run via OTA" while working with PushMIDlets. 7. Select Project | Run via OTA 8. In the Emulator, select Apps | Install Application . Notice that User Confirmation is required regarding the interruptive nature of the Push functionality. Respond in afffirmative for all the menus until the installation succeeds and you see the SMSPushDemo as one of the installed applications in the Emulator Window. Running the Push and Non-Push MIDlet ==================================== 9. In case, no other MIDlets other than the SMSPushDemo has been installed, go ahead and install the Games project. Click on the "Open Project" button, and select the "games" project. 10. Select Project | Run-via-OTA. In the emulator, select Apps | Install Application, and go through with installing the 'games' application. 11. Run the Games Application, by selecting Menu | Launch from the Emulator. The first app in the Games project, "TilePuzzle" is highlighted. Click Launch. 12. Make a note of the Phone Number automatically assigned to the emulator by the Wireless Toolkit. This will be in the top left corner of the window. For example, it will say some thing like: +5550003. 13. From the Emulator, Select File | Utilities. 14. In the Utilities, click on Open Console, Under the WMA Group. 15. Click on Send SMS. 16. Select the phone number which is exactly the same as the one in Step 12. **IMPORTANT** : Enter the Port Number as 50000 . Type some Text Message. Click on Send 17. Notice that in the Emulator, the execution of the "TilePuzzle" game is now interrupted to display a message that says, "Information is arriving for the SMSPushDemo. Is it ok to exit SunSamples - Games and launch SMSPushDemo" . Click OK. 18. In the next window, the next message says "SMSPushDemo wants to receive information..." Click OK. 19. Notice that what you have typed in the WMA console in Step 16, is now appearing under the title "Incoming SMS Message"... Suggested Exercises/Improvisations: =================================== One can augment this demo to do lot more interesting things. For example, you can make this SMSPushDemo MIDlet send a HTTP message to a Servlet with the SMS Message received.