[英]How to get all data from Qr code like Name, Email, Contact info programetically?
I use ZXingScannerView for scan Barcode and it shows only barcode type and content.我使用 ZXingScannerView 扫描条码,它只显示条码类型和内容。 But I want to extract full data from content like name, birth date, etc...
但我想从姓名、出生日期等内容中提取完整数据...
Scan result shown in the below image, its result of business card scan, it gives mixed content how can I extract all fields?扫描结果如下图所示,是名片扫描的结果,内容混合,如何提取所有字段?
Here Only two methods for this这里只有两种方法
How i separate all field like name, email, number, etc..我如何分隔所有字段,如姓名、电子邮件、号码等。
String format= rawResult.getBarcodeFormat().toString());
String Content=rawResult.getText());
You need to split the content by lines first, then decide how to deal with each line.您需要先将内容按行拆分,然后再决定如何处理每一行。
String[] lines = content.split("\n");
for (String line : lines){
String[] typeAndValue = line.split("[:;]", 2);
String type = typeAndValue[0];
String value = typeAndValue[1];
// ...do the voodoo that you do...
}
You can use the class ResultParser which is included in the zxing library.您可以使用 zxing 库中包含的 ResultParser 类。
...
import com.google.zxing.Result;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser;
...
ParsedResult parsedResult = ResultParser.parseResult(rawResult);
switch (parsedResult.getType()) {
case ADDRESSBOOK:
AddressBookParsedResult addressResult = (AddressBookParsedResult) parsedResult;
String[] addresses = addressResult.getAddresses();
String[] phoneNumbers = addressResult.getPhoneNumbers();
String[] emails = addressResult.getEmails();
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.