Add a hint to your barcode scanner

  1. Import the required classes.
    import java.util.*;
    
    import net.rim.device.api.barcodelib.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.container.*;
    
    import com.google.zxing.*;
  2. Create a Hashtable to store decoding hints in.
       Hashtable hints = new Hashtable();
  3. Create a new Vector object to store barcode formats in.
       Vector formats = new Vector();
  4. Add the BarcodeFormat.QR_CODE constant to the Vector object using Vector.addElement(Object obj). You can add more than one constant (hint) to a Vector object.
       formats.addElement(BarcodeFormat.QR_CODE);
  5. Invoke Hashtable.put(Object key, Object value), and add the Vector object to the hash table. The DecodeHintType.POSSIBLE_FORMATS constant is used to specify that the hints contained in the Vector object are barcode formats. Other constants for decoding hints can be found in the com.google.zxing.DecodeHintType class.
       hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
  6. Construct a BarcodeDecoder object, passing the Hashtable object into its constructor.
       BarcodeDecoder decoder = new BarcodeDecoder(hints);
Previous topic: Hints

Was this information helpful? Send us your comments.