Java Reference
In-Depth Information
Recognizing and Generating Visual Tags
Visual targets —a fancy name for bar codes, and you'll often see the interface specification
refer them to tags —provide an interesting avenue for mobile e-commerce applications,
because they are ubiquitous on product packaging today. In turn, this means that readers
for these targets are also commonplace, enabling applications such as the transfer of
credentials to readers for paperless tickets.
The support for visual tags in the Contactless Connection API is somewhat different
than for other contactless targets, because there might be no automated discovery
process. While your application can register with the DiscoveryManager , you can also initi-
ate manual scanning of a visual tag. If the user wants to scan a visual tag, it's up to her to
see the bar code, start your application, and have the application capture the bar-code
image using the MMAPI interface and present the image to the Contactless API for recog-
nition. In a similar vein, you can encode arbitrary data into a bar code and display it on
the screen, so the user can present a bar code to a bar-code scanner.
Bar codes come in different flavors, called symbologies . Some, such as European
Article Number/Universal Product Code (EAN/UPC), are one-dimensional, containing
a single stripe of information. Other, newer bar codes, such as Quick Response Code
(QR Code), are two-dimensional squares or rectangles of information. These two-
dimensional bar codes can encode more information, and applications often use them
to carry URLs or other information. When using the visual tag interface, you first need
to ascertain whether the symbology you desire is supported by the implementation.
You determine the list of supported symbologies by invoking the static SymbologyManager.
getReadSymbologies method, which returns an array of strings naming the supported
symbologies. Table 15-1 shows a list of potentially supported symbologies.
In addition to being symbology-agnostic, the Contactless Communication API is
image format-agnostic. The SymbologyManager keeps a list of supported image classes that
the implementation can decode or encode; you can obtain these lists through the static
method SymbologyManager.getImageClasses . This method returns an array of supported
Class instances; you can then peruse this list to see if the implementation supports a
specific image type.
Once you ascertain support for your desired symbology and image type, it's time
to perform the encoding or decoding. You do this using a VisualTagConnection object,
which you obtain by opening a Connector to the URI "vtag://" . The resulting instance
of VisualTagConnection can perform the necessary encoding or decoding. It's kind of
odd to use a Connection subclass to do something besides establish a connection, but
that's how the Contactless Connection API specifies the interface; it at least provides
conceptual parity with the other contactless interfaces.
 
Search WWH ::




Custom Search