2012-06-14 5 views
0

Я ищу библиотеку, заплаченную или с открытым исходным кодом для сканирования штрих-кода для Blackberry. Я нашел один. т.е. zxing. Если вы знаете об этом, предложите другие библиотеки.Barcode Сканирующая библиотека для Blackberry, отличная от Zxing

Я хочу библиотеку, которая может читать/сканировать штрих-код. Код 25. Пожалуйста, помогите мне в этом.

Благодаря

+0

см http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/barcodelib/BarcodeScanner.html – Signare

+0

http://sourceforge.net/projects/readbarj/ – Signare

+0

I нужна библиотека, такая как zxing. оплачивается ли он или с открытым исходным кодом. – user123456

ответ

0
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.*; 
Create a class to run the application by extending UiApplication. 
public final class BarcodeScanDemo extends UiApplication 
{ 
Create a constructor for the class, and display a BarcodeScanDemoScreen object. 
    public BarcodeScanDemo() 
{ 
    pushScreen(new BarcodeScanDemoScreen()); 
} 
Create the main method that starts the application. 
    public static void main(String[] args) 
    { 
     new BarcodeScanDemo().enterEventDispatcher(); 
    } 
} 
Define a screen for your class that extends the MainScreen class. 
final class BarcodeScanDemoScreen extends MainScreen 
{ 
Create a constructor for the screen. 
    public BarcodeScanDemoScreen() 
    { 
Create a BarcodeDecoderListener object to handle the data that is received when a barcode is scanned. In it, implement barcodeDecoded() to process the raw data that is sent by the decoder. 
     BarcodeDecoderListener listener = new BarcodeDecoderListener() 
     { 
      public void barcodeDecoded(String rawText) 
      { 
       // Do something with the raw text 
      } 
     }; 
Create a Hashtable to store decoding hints in. 
     Hashtable hints = new Hashtable(); 
Create a new Vector object to store barcode formats in. 
     Vector formats = new Vector(); 
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); 
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); 
Construct a BarcodeDecoder object to decode data received from the camera's viewfinder into usable raw data. Pass the Hashtable object into it. 
     BarcodeDecoder decoder = new BarcodeDecoder(hints); 
Create a try block, and construct a MainScreen object to contain the camera viewfinder. 
     try 
     { 
      MainScreen screen = new MainScreen(); 
Construct a BarcodeScanner object, and pass the BarcodeDecoder and BarcodeListener objects into it. Invoke BarcodeScanner.getVideoControl() to return a VideoControl object. Invoke VideoControl.setDisplayFullScreen(true) to set the video's display to full screen. 
      BarcodeScanner scanner = new BarcodeScanner(decoder, 
             listener); 
      scanner.getVideoControl().setDisplayFullScreen(true); 
Invoke Screen.add(Field field) to add the barcode scanner's view finder to the screen, then invoke UiApplication.pushScreen(Screen screen) to display the viewfinder. 
      screen.add(scanner.getViewFinder()); 
      UiApplication.getUiApplication().pushScreen(screen); 
Start the barcode scanner by invoking BarcodeScanner.startScan(). Close the try block. 
      scanner.startScan(); 
     } 
Open a catch block to catch any errors that may occur. 
     catch (Exception e) 
     { 
      // Catch errors here 
     } 
    } 
} 
+0

приведенный выше код - http://docs.blackberry.com/en/developers/deliverables/29251/Create_a_barcode_scanner_1585041_11.jsp – Signare

+0

Спасибо за код. Это будет работать только для BB OS> 6.0. Мне нужна библиотека, как zxing. – user123456

1

Просто, чтобы указать, что код 25 (AKA 2 из 5, и его чередования варианта) декодируются Андроид Barcode Scanner, который, в свою очередь, использует ZXing. (Несмотря на официально, страница проекта ZXing не отображает ее как поддерживаемую).

Вы можете загрузить последнюю версию ZXing и переупаковать ядро ​​для BB с разными именами пакетов, чтобы они не сталкивались со встроенными библиотеками ZXing (которые являются более старой версией) и проверяют их.

+0

О, спасибо ... Я обязательно попробую это. Может быть, это поможет, но что, если я не хочу идти с библиотекой zxing и использовать другие библиотеки? которые доступны для BB – user123456

Смежные вопросы