I'm using compile 'com.google.android.gms:play-services:10.2.0' (https://developers.google.com/android/reference/com/google/android/gms/vision/barcode/Barcode.html#valueFormat) to read QR code. I want to be compare my read QR to a String. If it matches, it should display a message.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null) {
final Barcode barcode = data.getParcelableExtra("barcode");
// I also tried barcode.displayValue!
final String password = barcode.rawValue;
if (password == "123456") {
resultText.post(new Runnable() {
@Override
public void run() {
resultText.setText("Sucess");
}
});
When I display my QR code, it reads 123456, but comparing it to "123456" doesn't work.
I thought displayValue and rawValue were casting my QR into a string. Does anyone have any idea? Thanks