Skip to content

Instantly share code, notes, and snippets.

@misto
Last active August 11, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misto/fe6e36338b5a29ec7e9f1765a20ac41e to your computer and use it in GitHub Desktop.
Save misto/fe6e36338b5a29ec7e9f1765a20ac41e to your computer and use it in GitHub Desktop.
Scan and Decode QR-Code
public void takeQrCodePicture() {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setCaptureActivity(MyCaptureActivity.class);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setOrientationLocked(false);
integrator.addExtra(Intents.Scan.BARCODE_IMAGE_ENABLED, true);
integrator.initiateScan();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IntentIntegrator.REQUEST_CODE
&& resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
String path = extras.getString(
Intents.Scan.RESULT_BARCODE_IMAGE_PATH);
// Ein Bitmap zur Darstellung erhalten wir so:
// Bitmap bmp = BitmapFactory.decodeFile(path)
String code = extras.getString(
Intents.Scan.RESULT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment