@Override
public void onClick(View v) {
if (v.getId() == R.id.scan_button) {
Log.i("result", "START SCAN");
IntentIntegrator scanIntegrator = new IntentIntegrator(
BarcodeScan.this);
scanIntegrator.initiateScan();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.startActivityForResult(intent, resultCode);
Log.i("result", "Result Out");
if (requestCode == 0) {
IntentResult scanningResult = IntentIntegrator.parseActivityResult(
requestCode, resultCode, intent);
if (resultCode == RESULT_OK) {
if (scanningResult != null) {
String scanContent = scanningResult.getContents();
DatabaseAdapter mDbHelper = new DatabaseAdapter(this);
mDbHelper.createDatabase();
mDbHelper.open();
BookController bc = new BookController(mDbHelper.open());
Log.i("result", scanContent);
String bookID = bc.getBookIDByBarcode(scanContent);
System.out.println(bookID);
intent = new Intent(context, ReserveBook.class);
intent.putExtra("BookID", bookID);
startActivity(intent);
this.finish();
} else {
Toast toast = Toast.makeText(getApplicationContext(),
"No scan data received!", Toast.LENGTH_SHORT);
toast.show();
}
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Log.i("App", "Scan unsuccessful");
}
}
}
I am implementing Zxing Barcode Scanning into my app, I am able to scan the barcode, but after scan the apps was stop. In the LogCat, the START SCAN got printed out. After that the app close.