Using the Share API

Implementing a sharing source

The sharing source has some kind of content available, for example, an image edited by the user or an HTTP URL pointing to some interesting Web page. Sharing is initiated by calling the share content handler via the JSR 211 API. Below, you can see how this could be done in Java.

registry = Registry.getRegistry(this.getClass().getName());
Invocation invocation = new Invocation(null, null, "");

The this in Registry.getRegistry(this.getClass().getName()) refers to the instance of the MIDlet.

The important parts above are that share handler is registered with handler id "" which needs to be passed to the Invocation class constructor. The action used for sharing is "share". The data regarding this specific share invocation is passed in the invocation arguments array. See the documentation below about supported arguments for details.

Implementing a sharing destination

Implementing sharing destination is done by registering the application to handle certain MIME types for the "share" action. The registration can be done either statically or dynamically as defined by the JSR 211 specification.

When sending multiple files with different MIME types, a wildcard character is used to mark the variety. For example, if sharing one "image/jpeg" and one "image/png", "image/*" should be used as the MIME. If the set of files don't share even the prefix of the MIME, then "*/*" should be used.

Supported share types

For the share support within device, it can be triggered from different applications:

  • Support sharing link and bookmark from Browser.

  • Support sharing files from gallery, music player, video player, camera and so on.

  • Support sharing contacts and calendars.

To support the share types in Java MIDlets, the following MIME types can be registered:

  • image/* or specific image types

  • audio/* or specific audio types

  • video/* or specific video types

  • text/plain type

When a Java MIDlet receives the invocation, it can retrieve the arguments. Arguments are passed as key-value-pairs in the args array of the Invocation instance. Key and value is separated with "=". It is possible that some key is present multiple times, for example, in case multiple files are being shared, the "url"-key is present as many times as there are files.

  • url - The url to the file that is being shared (many supported) n. This is used when the shared items are files.

  • text - Textual content that is being shared. This is used when the shared items are text content.

If the MIDlet supports fast lane integration, additional arguments can be included:

  • id - A unique identifier of the share transaction that can be stored by the destination for future referencing. This can be used by the MIDlet when open-shared action is invoked.

Last updated 20 November 2013

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.