public class QRCodeScan extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentIntegrator integrator = new IntentIntegrator(QRCodeScan.this);
integrator.initiateScan();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent){
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (result.getContents() != null){
contents = result.getContents();
Intent qrCodeIntent = new Intent();
qrCodeIntent.putExtra("QRCode_content", contents);
setResult(Activity.RESULT_OK,qrCodeIntent);
finish();
}
else {
setResult(RESULT_CANCELED);
finish();
}
}
}