Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

anbillon/Android-BarCodeScanView

Open more actions menu

Repository files navigation

BarCodeScanView

Bar/QR code scan view and generator library.

Usage

  • Barcode scan. First, add BarCodeScanView in your layout:
<com.anbillon.barcodescanview.BarCodeScanView
      android:id="@+id/qr_code_scan"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:labelTextSize="16sp"
      />

Then get BarCodeScanView to use:

public class MainActivity extends AppCompatActivity
    implements View.OnClickListener, BarCodeScanView.OnCameraErrorListener,
    BarCodeScanView.OnBarCodeReadListener {
  private BarCodeScanView barCodeScanView;

  @SuppressWarnings("ConstantConditions") @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    barCodeScanView = (BarCodeScanView) findViewById(R.id.qr_code_scan);
    /* set auto focus internal */
    barCodeScanView.setAutofocusInterval(1000L);
    barCodeScanView.setOnClickListener(this);
    /* you will receive error if failed to open camera */
    barCodeScanView.setOnCameraErrorListener(this);
    /* receive bar code scan result */
    barCodeScanView.setOnBarCodeReadListener(this);
  }

  @Override public void onClick(View v) {
    barCodeScanView.restart();
  }

  @Override public void onCameraError(String errorMsg) {
    Toast.makeText(this, "Camera error", Toast.LENGTH_SHORT).show();
  }

  @Override public void onBarCodeRead(Result result) {
    Toast.makeText(this, "result: " + result.getText(), Toast.LENGTH_LONG).show();
  }
  • Barcode generator:
/* 1d barcode */
Bitmap 1dBitmap = Encoder.generateBarcodeBitmap("1d barcode", 100, 100);
/* 2d barcode */
Bitmap 2dBitmap = Encoder.createQRCodeBitmap("2d barcode", 100);
  • Support attributes:
Name Description
labelText Set the text on BarCodeScanView
labelTextSize Set the text size of label
shouldPlayBeepAndVibrate Should play beep and vibrate when bar code is decoded

Download

compile 'com.anbillon.barcode.barcodescanview:1.0.0-SNAPSHOT'

About

A convenient bar code scan view library to integrate zxing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.