-5

i have a android phone with a build in rfid scanner for barcodes which and i wonder if there some how a way i can get this scanner to only paste the decoderesult to cardnumberbox only if it starts with a K otherwise only paste it to shelfnumberbox if it starts with an R

public void handleMessage(Message msg) {
    HashMap<String, String> result = (HashMap<String, String>) msg.obj;
    switch (msg.what) {
        case GET_CODE_CASE:
            if (!isScanTimeOut()) {
                cardnumberbox.setText(result.get("decodeResult"));
            } else {
                if (toast != null) toast.cancel();
                toast = Toast.makeText(CameraActivity.this, R.string.try_again,
                        Toast.LENGTH_SHORT);
                toast.show();
            }
            scanCase = 0;
            break;
        default:
            break;
    }
}
};
omini data
  • 407
  • 7
  • 29

1 Answers1

2

You can find information like this yourself if you have sources installed and simply look at the classes (in this case the string class)

String decoderesult = result.get("decodeResult");
if (decoderesult.toLowerCase().startsWith("k")) {
    cardnumberbox.setText(decoderesult);
} else if (decoderesult.toLowerCase().startsWith("r")) {
    shelfnumberbox.setText(decoderesult);
}
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124