Moseycode Intents

The Moseycode application can be invoked from Android applications for the purpose of reading barcodes. Execution is temporarily ceded to Moseycode (by launching a sub-activity with a particular intent) for a user to scan a barcode at which point control is returned to the originating application along with information about the barcode(s) scanned. By design, the Moseycode user interface is completely uncluttered and should 'gel' with any style of application.

In principle, there is one way that Moseycode can currently be used from other applications: as sub activity to scan images containing barcodes; what can be varied is where the images are sourced and the information that is returned.

Intent Actions

There is one action that can be used to invoke Moseycode as a sub activity:

Behaviour of the Moseycode activity is customized via the data URI and extras bundle.

Data URIs

The data URI of the intent specifies the source of the image(s) to be scanned for barcodes. At present four schemes are supported:

downloads an image over HTTP. The image format must be supported by the Android platform (at present JPEG or PNG).
uses the Android platform's content URI system to obtain the image data. Moseycode will obtain an the image via getContentResolver().openInputStream(data). The image format used must be one supported by the Android platform.
obtains an image as a Bitmap that has been stored as a property of the intent's extras bundle. For example, for the URI property://photo Moseycode will obtain the image data via (Bitmap) intent.getExtra("photo"). Note: Subject to future feedback on performance and memory usage, this scheme may be removed.
obtains a sequence of images from the device's camera. The URI camera://0 refers to the primary camera on the device. Since the Android platform does not currently support multiple camera devices, this is the only valid URI.
File URLs (file://) are not currently supported, support has been deferred until anticipated changes to the operation of the Android file system have been published.

Note that for any of the above schemes, a data type must be specified so that the intent will match the Moseycode IntentFilter. In the case of the http and conten6 schemes, the image mime type should be used (eg. image/jpeg or image/png) otherwise image/* should be used.

In the case of moving images (ie. from a camera) the Moseycode activity will not finish until a barcode has been resolved (or the user cancels the activity by pressing the back button). For still images the activity will will finish if no barcode is located immediately.

Extra Parameters

The Moseycode activity can be further customized by supplying extra parameters to the Intent used to launch it.

message (type: String)
Provides a messages that is overlayed onto the screen while Moseycode is searching for barcodes. This can be used by applications to instruct the user within the context of their application.
return (type: String)
Indicates the degree of barcode information that the invoking application wants returned. At present the only supported value is "RAW" which returns the raw portal data. In the future, "CHAMBER" (which returns a fully resolved chamber definition) and "URL" (which returns the target URL of the barcode – if there is one) will be supported. If this proprerty is omitted "RAW" is assumed.
At present, there are few supported launch parameters. It is envisioned that there will be many more in the future.

Activity Results

If the Moseycode activity doesn't fail (in the context of the Activity system). The results of the barcode scan will be communicated in the extras bundle passed to the Activity.onActivityResult method.

The bundle will contain properties named barcode/0, barcode/1, … one for each barcode that was identfied. Such properties are guaranteed to be contiguously numbered. If no barcodes were found, there will be no such named property. The order in which barcodes are reported is undefined.

The property associated with each of these names is itself a Bundle that contains information relating to that barcode. The following properties are supplied:

type (type: String)
The type of barcode scanned, at this time always "Mosey".
result (type: String)
The type of data being returned, at this time always "RAW".
chamberId (type: int)
Identifies a chamber – the digital contents of the barcode.
shortData (type: short)
Provides 16 bits of supplementary information for the barcode.
intData (type: int)
Provides a further 32 bits of supplementary information for the barcode.
checksum (type: short)
A checksum derived from the chamberId, shortData and intData.

For some information about how to interpret these numbers see the Moseycode Encoding documentation. Of course, your application is free to interpret the data in any way that it wants.

Usage Examples

A fully documented sample Android application that demonstrates how to use Moseycode in your own applications is provided with this release. See the release page for links to download the demo application and its source code.