Imagine a mobile application that can be registered to handle a MIME type, then present content of that type, and you've grasped the purpose of the Content Handler API (CHAPI): enabling applications based on the Java 2 Platform, Micro Edition (J2ME) to handle a lavish diversity of multimedia and web content. A key goal is the possibility of integrating microbrowsers with applications seamlessly. Developed in the Java Community Process (JCP) as JSR 211, CHAPI defines an optional package of APIs and an execution model that enables applications to invoke J2ME and non-Java applications by URL, MIME type, or content handler ID. This tech tip introduces you to the Content Handler API and hints at some of the many uses to come. The Content Handler API (JSR 211)
A content handler is any application that registers itself to handle some kind of content, responds to requests for such content, and serves it up to the user. The Content Handler API is an optional package, designed to work with version 2.0 of the Mobile Information Device Profile (MIDP 2.0), the Personal Basis Profile (PBP), and other compatible profiles. The JSR 211 specification defines functions to:
A link to desired content might reach the user's device in an SMS message, a browser, or even from another application, at which point the device's software manager would dispatch the matching application. Sample Scenarios
Perhaps the most interesting aspect of the Content Handler API is its goal of seamless integration between the device's browser and the applications. The browser is crucial to this optional package, as it can be used to invoke other content handlers. A few of the many operating scenarios we can expect include:
Architecture
JSR 211 does not dictate CHAPI's position in a device's software architecture, but for reference and discussion it does provide a sample architecture that will look very familiar to users of J2ME optional packages. Figure 1, from the CHAPI specification, depicts the relationships between the Content Handler API, configurations and profiles, and other optional packages, and is suggestive of typical interface and behavior.
Contents of the Optional Package
The
Registration of Content Handlers
Registration should occur when the application is installed. You define registration behavior by setting attributes in the Java Application Descriptor (JAD) file. In this sample JAD file the attributes in bold text support content handlers:
At this writing, CHAPI has no reference implementation, but if you'd like to see what's involved in using the Content Handler API, look into Appendix A of the JSR 211 specification. It furnishes an example content handler for displaying images that can be found. For More Information
About the Author
| ||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||