I would like to suggest you one other way. download this project and add BarCodeScanner
for opening an bar code scanner on any click event call this capture activity form intent like this :
Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
startActivityForResult(intent, 2);
OnActivityResult()
onActivityResult(requestCode, resultCode, data);
if (data != null) {
if (requestCode == 2) {
if (data.getParcelableExtra("BitmapImage") != null) {
img.setVisibility(View.VISIBLE);
img.setImageBitmap((Bitmap) data
.getParcelableExtra("BitmapImage"));
}
if (data.getStringExtra("BarcodeFormate") != null
&& !TextUtils.isEmpty(data
.getStringExtra("BarcodeFormate"))) {
bBarcodeFormate.setVisibility(View.VISIBLE);
bBarcodeFormate.setText("Barcode Formats " + data
.getStringExtra("BarcodeFormate"));
}
if (data.getStringExtra("Type") != null
&& !TextUtils.isEmpty(data.getStringExtra("Type"))) {
bType.setVisibility(View.VISIBLE);
bType.setText("Type " + data.getStringExtra("Type"));
}
if (data.getStringExtra("DateFormate") != null
&& !TextUtils.isEmpty(data
.getStringExtra("DateFormate"))) {
bDateFormate.setVisibility(View.VISIBLE);
bDateFormate.setText("Date Formate " + data.getStringExtra("DateFormate"));
}
if (data.getStringExtra("MetaData") != null
&& !TextUtils.isEmpty(data.getStringExtra("MetaData"))) {
bmetaDataText.setVisibility(View.VISIBLE);
bmetaDataText.setText("MetaData " + data.getStringExtra("MetaData"));
}
if (data.getStringExtra("DisplayContents") != null
&& !TextUtils.isEmpty(data
.getStringExtra("DisplayContents"))) {
dDisplayContents.setVisibility(View.VISIBLE);
dDisplayContents.setText("Display Contents " + data
.getStringExtra("DisplayContents"));
}
}
}
}
If you have any doubt or issue let me know.
by this you have no need install third party app for bar code scanner