Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.4 for Eclipse on Windows
  Go To Table Of Contents
Go To Index


22 JSR 211: Content Handler API (CHAPI)

JSR 211 defines the Content Handler API (CHAPI). CHAPI specifies a system by which MIDlets can be launched in response to specific types of content.

The basic concept is that MIDlets can be launched in response to incoming content (files). Modern mobile phones can receive content using SMS, infrared, Bluetooth, e-mail, and other methods. Most content has an associated content type.

22.1 Using Content Handlers

In the Oracle Java ME SDK Content Handlers are integrated in an Eclipse project as application descriptors. Content Handlers you define are packaged with the application.

22.2 Running the CHAPIDemo Content Browser

This demo is a content browser that takes advantage of the content handler registry. It enables you to view different types of content from different sources.


For the demo to work this project must reside in the Oracle Java ME SDK installation's \apps subdirectory. You must create this directory yourself. For example, C:\Java_ME_platform_SDK_3.4\apps.

  1. If your workspace is the Oracle Java ME SDK installation's \apps subdirectory, continue to step 2. If not, follow these steps to create the workspace:

    • Create an \apps directory in your Oracle Java ME SDK platform installation. For example, C:\Java_ME_platform_SDK_3.4\apps.

    • In Eclipse, select File > Switch Workspace > Other.

    • Browse to the \apps directory, and click OK.

  2. Select File > New > Project... and in the New Project window, select Examples > Java ME SDK 3.4 > Java ME Sample Applications, and click Next.

    Select CHAPIDemo.

  3. Right-click a device and select Run Project via OTA > CHAPIDemo.

    Not all features of the demo are available if you select the Run command. Additionally, to see certain features of the demo, an HTTP server is required. The server is located in the installdir\apps directory. Also the audio and video files are located in the content directory, which must be located in installdir\apps\CHAPIDemo directory (installdir\apps\CHAPIDemo\content).

  4. On the Favorite Links page, select CHAPI Demo.

  5. Press Select or click the Menu soft button and select Go.

    You might see a request for permission to use airtime. To speed up the demo interaction, select "Ask once per application use" and select the Yes soft key (if you do not check this option you can still use the demo but you see the airtime message more frequently).

    The Text Viewer displays a Media Player URL and links to various media files.

  6. Install the Media Player to view media.

    • Click the URL http:handlers/dist/MediaHandler.jad, or, use arrow keys to highlight the URL and from Menu, select Go.

    • The application asks, "Are you sure you want to install Media Handler?" Click the Install soft key.

      An authorization Information screen is displayed.

    • Click the Install soft key.

      The installation is confirmed. When the installation completes, you are returned to the Text Viewer. The Media Handler is shown as a separate application in the AMS.

  7. Select and view the different image, video, audio and text URLs.

    Click a link to open that media in the viewer, or, use arrows to highlight the link, then select Go from the soft menu.

    Select the Back soft key to return to the Text Viewer.