Last active
August 11, 2016 12:47
-
-
Save misto/fe6e36338b5a29ec7e9f1765a20ac41e to your computer and use it in GitHub Desktop.
Scan and Decode QR-Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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