Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Sun's New Wireless Toolkit Keeps Up with the Mobile Joneses : Page 5

As devices grow more capable, so too must our development and emulation testing environments grow. Find out how this first of two anticipated beta releases of the newly renamed Wireless Toolkit from Sun addresses many J2ME developer needs as well as adding support for new APIs.


advertisement
Content Handler API Support
The last of the new APIs supported by WTK 2.3 is the Content Handler API (CHAPI). CHAPI is another optional package meant to work with Mobile Information Device and Personal Basis Profiles. Similar to the way Windows allows you to associate particular applications on the desktop to certain file types (for example double clicking on a file with an .html extension causes the browser to start and display the HTML file), the CHAPI API allows MIDlets on a device to be associated with a specific type of content. When the device encounters content of a specific type, it can call on one of the associated MIDlets to take action with the content.

For example, a certain MIDlet can be associated with MIME type image/png. When the device encounters content of image/png type, it can call on the MIDlet to help display or modify the content.

CHAPI provides the means to invoke a content handler (a MIDlet) and get a response, register a content handler (a MIDlet) on the device with content type, query registrations, and respond to an invocation. If you are wondering where you might use this functionality, the CHAPI specification provides eight use cases to illustrate how CHAPI might be used (see Table 2).



Table 2. CHAPI Use Cases: The CHAPI specification provides eight use cases or illustrations of how CHAPI might be useful to J2ME developers. See the JSR-211 Specification for more details on these use cases.

Use Case 1: Distributing new game levels

Use Case 2: Sending coupons to customers

Use Case 3: Receiving a snapshot

Use Case 4: Buying a Music-Clip

Use Case 5: Upgrading software with new features

Use Case 6: Invoking content stored on the device

Use Case 7: Invoking a specific application

Use Case 8: Getting an email address from a local or remote phone book


How does the new WTK support CHAPI? A new tab in the Project Settings dialog window (see Figure 12) allows you to associate or "register" MIDlets with content types and file suffixes.

The WTK 2.3 comes with a CHAPI demonstration application. It is called CHAPIDemo and it can be found in the \apps directory of the WTK 2.3 download. This application provides an example of how to launch MIDlet viewers based on the request for a certain type of file. The CHAPIDemo has two viewers: an image viewer for image/png files and a text viewer for text/plain content. Based on the selection of particular URLs from the demonstration application, the viewers for a particular file are launched in order to open and view the content requested. Figure 13 shows how the two MIDlet viewers are registered in the Content Handler API.


Figure 12. The Content Handler Tab: The Project Settings dialog window has a new Content Handlers tab (shown on the left) that depicts which MIDlets have been associated to various content and file types. The Add button on this tab allows you to register a MIDlet with content or file types in the "Enter content handler details" window (on the right).
 
Figure 13. Registered Viewers for Text and PNG Files: The CHAPI Demo application that comes with WTK 2.3 provides an example of how to register and use MIDlets to view text or images in an appropriate viewer based on the content request.

NetBeans Integration
If you use the NetBeans IDE (see my earlier article, "Mobile Java Gets a Much-needed Boost from Sun's New Mobility Toolkit," for more on NetBeans), you might be familiar with the fact that NetBeans allows the selection/use of an emulator engine. While not officially integrated yet, the latest version of NetBeans allows you to use WTK 2.3 as the NetBeans emulator. To integrate NetBeans with WTK 2.3, open a J2ME project's properties dialog in NetBeans, push the Manage Emulators button and use the Java Platform Manager to point NetBeans to the WTK 2.3 directory (see Figure 14). You can also add the emulator through Tools | Java Platform Manager.


Figure 14. NetBeans Integration: To select WTK 2.3 as the emulator for NetBeans J2ME projects, open a project's Properties dialog box, as shown, and press the "Manage Emulators…" button.
 
Figure 15. NetBeans Integration: In the next dialog box, select the "Add Platforms…" button and point NetBeans to the WTK 2.3 directory.

The final release of Mobility Pack 5.0 (expected any day now) is anticipated to have improvements that will help you find and add a new SDK like WTK 2.3.

Wrap Up
As mentioned earlier in this article, Sun plans to release another beta version of the Java Wireless Toolkit 2.3 in early 2006 and then have a final release in the second quarter. Plans are to have WTK also support the new Mobile Service Architecture for CLDC (JSR 248), SIP API (JSR 180), Scalable 2D Vector Graphics API (JSR 226), Payment API (JSR 229), Advanced Multimedia Supplements (JSR 234), and the Mobile Internationalization API (JSR 238); a lot of new capability for a single release. As devices grow more capable, so too must our development and emulation testing environments grow. Hail to the WTK and other IDEs for trying to keep up.



Jim White is an instructor with Intertech Training. He is also co-author of Java 2 Micro Edition, (Manning).
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap