So I have RegisterActivity.java, where after user click register, it should call ScanActivity() method in ScanActivity.java.
In ScanActivity(), it will start scanning activity, and return the scan result back to RegisterActivity.java.
Using the scan result, the validation of user will occur in RegisterActivity.java.
How to do this?
In RegisterActivity.java
// call ScanActivity
ScanActivity scanActivity = new ScanActivity();
// get scan result from ScanActivity
String scanResult = scanActivity.ScanActivity();
// compare with useridtxt
// if useridtxt same with scan result, start save into parse
if (useridtxt.equals(scanResult)) {
// some code here
} else if (!useridtxt.equals(scanResult)) {
// some code here
} else {
// some code here
}
In ScanActivity.java
public class ScanActivity extends Activity {
public static final int CODE39 = 39;
private static final int ZBAR_SCANNER_REQUEST = 0;
String ScanActivity() {
Intent intent = new Intent(this, ZBarScannerActivity.class);
intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.CODE39});
startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
String scanResult = getIntent().getStringExtra(ZBarConstants.SCAN_RESULT);
return scanResult;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
// maybe save the scan result here, and pass it to String scanResult in RegisterActivity.java?
} else if(resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Camera unavailable", Toast.LENGTH_SHORT).show();
}
}