I think its wise to implement the bar code functionality in your app. So I stumbled on this easy library. It seem like a union of zxing and zbar but much easier to interpret. Visit this git-hub repo https://github.com/dm77/barcodescanner
How to start:
Add the following dependency to your build.gradle file.
compile 'me.dm7.barcodescanner:zxing:1.7.2'
or
compile 'me.dm7.barcodescanner:zbar:1.7.2'
Then make a simpleScannerActivity and add this code.
public class SimpleScannerActivity extends Activity implements ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
mScannerView = new ZXingScannerView(this); // Programmatically initialize the scanner view
setContentView(mScannerView); // Set the scanner view as the content view
}
@Override
public void onResume() {
super.onResume();
mScannerView.setResultHandler(this); // Register ourselves as a handler for scan results.
mScannerView.startCamera(); // Start camera on resume
}
@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera(); // Stop camera on pause
}
@Override
public void handleResult(Result rawResult) {
// Do something with the result here
Log.v(TAG, rawResult.getText()); // Prints scan results
Log.v(TAG, rawResult.getBarcodeFormat().toString()); // Prints the scan format (qrcode, pdf417 etc.)
}}