This class provides methods to invoke, register, unregister, and query information about content handlers. Your application can register zero or more content types (for example, image/bmp), suffixes, and actions.
The application gains access to the registry by invoking the getRegistry() method and passing in a classname parameter. The classname parameter is a String that uniquely identifies the application with the Registry class.
The Registry class also provides methods to access the ContentHandlerServer class using the getServer() method. Like the getRegistry() method, the getServer() method requires a classname parameter that uniquely identifies the application with the ContentHandlerServer class.
The sample application uses this class to register this application as a content handler for the content types image/bmp, image/png, image/jpeg, video/3gpp, and video/mp4.
The sample application passes in the String, com.rim.samples.device.sendmediademo.SendMediaDemo, as the classname parameter in the getRegistry() and getServer() methods to uniquely identify this application in the Registry and the ContentHandlerServer, respectively.
This class contains methods to access the information that is contained in the request that an invoking application passes to a content handler. The results of the request are then passed to the content handler application through the ContentHandlerServer.getRequest() method.
The sample application retrieves the invocation from the invoking application (for example, the camera application) through the ContentHandlerServer using the ContentHandlerServer.getRequest() method in the sample application's invocationRequestNotify() method.
The sample application then uses the getType() method to extract the file type that the invoking application has sent to the sample application. After checking whether the file is an image or a video file, the sample application prepares the file for display. Depending on the file type, the application must perform different actions to display the file; however, in both cases, the location of the file to be displayed is retrieved using the getURL() method.
This class provides functionality to map actions to action names. An ActionNameMap object is one of the parameters that the the Registry.register() method requires.
The ActionNameMap constructor takes two String arrays, actions and actionnames, as parameters. The ActionNameMap object maps the String, actions, at position i to the actionnames String at position i. For an application that registers itself as a content handler on the BlackBerry® device, the actions parameter should be one of the constants that the ContentHandler interface in the javax.mocroedition.content package provides. This parameter defines the functionality that the content handler provides. For example, if your content handler can print the file that is being handled, you would add ContentHandler.ACTION_PRINT as one of the entries in the actions array. Other applications can find your content handler if they use the Registry.findHandler() method to search for a content handler on the BlackBerry device that has registered itself with the appropriate action constant.
The ActionNameMap constructor also takes in a locale parameter. This is a required parameter that must correspond with the locale syntax conventions that are defined in the ContentHandler class.
In the sample application, the ActionNameMap object is created in the sample application's register() method. The Registry.register() method takes an ActionNameMap array as a parameter, therefore the sample application creates the ActionNameMap object as an array with a single entry.
The ActionNameMap object maps the ContentHandler.ACTION_SEND action to the name of the menu item Send to demo app. Typically, the ContentHandler.ACTION_SEND constant signifies that the handler application provides functionality to send the content by email messaging or instant messaging. The feature that this application demonstrates would likely not be used to send content by email messaging or instant messaging, but would be used to handle the content in an application-specific way, such as sending the content over an HTTP connection.