Skip to content

Instantly share code, notes, and snippets.

@misto misto/MyActivity.java
Last active Aug 11, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.