Solution 1 :
Zxing’s result.text gets you a string of the content of the QR Code. you could create a function to get the value that you want.
val trxnRefId = result.text.substringAfter(&tr=).substringBefore(&tn=)
Problem :
Using the Zxing library I am generating QR Code for UPI transactions.
Below is the string
String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
+ "&tr=" + trxnRefId
+ "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode+ "&ad="+ str ;
Using Zxing Scanner, how to read values one by one like transaction reference id, amount and payee name.
Present I am getting a full string of UPI using the below code.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
Toast.makeText(this, "Scanned: " + result.getContents(),
Toast.LENGTH_LONG).show();
}
Comments
Comment posted by Niranjan Reddy
I can not able to get text object and substringAfter method
Comment posted by Mateo Hervas
That is because of the onActivityResult. First get your result.getContents and check what content do you have on it. you should have the result of the scan by zxing as a string. then you can do the