QR Scanning library based on zxing for android devices API 15 and up
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.blikoon:QRCodeScanner:0.1.2'
}
Be sure to check the latest version here
private static final int REQUEST_CODE_QR_SCAN = 101;
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this,QrCodeActivity.class);
startActivityForResult( i,REQUEST_CODE_QR_SCAN);
}
And catch the scan result:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode != Activity.RESULT_OK)
{
Log.d(LOGTAG,"COULD NOT GET A GOOD RESULT.");
if(data==null)
return;
//Getting the passed result
String result = data.getStringExtra("com.blikoon.qrcodescanner.error_decoding_image");
if( result!=null)
{
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Scan Error");
alertDialog.setMessage("QR Code could not be scanned");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
return;
}
if(requestCode == REQUEST_CODE_QR_SCAN)
{
if(data==null)
return;
//Getting the passed result
String result = data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult");
Log.d(LOGTAG,"Have scan result in your app activity :"+ result);
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Scan result");
alertDialog.setMessage(result);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
}
https://github.com/blikoon/QRCodeScanner/tree/master/app
https://www.youtube.com/watch?v=R9JxDpKpkAk
GPLv3
Submit a github issue
If you need one of our Commercial Services then do Contact us otherwise shoot us in the comments section of This librarie's article.We won't respond to general usage questions posted as github issues.