您需要仔細檢查電子郵件地址是否有多於一個,在本例中我只考慮了一封電子郵件。如果你看到email.getTos()方法,你會看到這是一個String []。
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
Result res = new Result(scanResult.getContents(), null, null, BarcodeFormat.QR_CODE);
ParsedResult parserdResult = ResultParser.parseResult(res);
Log.d("GORIO", "TYPE: " + parserdResult.getType().toString());
switch (parserdResult.getType()) {
case ADDRESSBOOK:
Log.d("GORIO", "ADDRESSBOOK: " + parserdResult.getDisplayResult());
break;
case EMAIL_ADDRESS:
Log.d("GORIO", "EMAIL_ADDRESS: " + parserdResult.getDisplayResult());
EmailAddressParsedResult email = (EmailAddressParsedResult) parserdResult;
if (email.getTos().length > 0)
Log.d("GORIO", "E-mail: " + email.getTos()[0] + " Subject: " + email.getSubject() + " Body: " + email.getBody());
break;
case PRODUCT:
ProductParsedResult prod = (ProductParsedResult) parserdResult;
Log.d("GORIO", "PRODUCT: " + scanResult.getContents());
break;
case URI:
URIParsedResult uri = (URIParsedResult) parserdResult;
Log.d("GORIO", "URI: " + scanResult.getContents());
break;
case GEO:
GeoParsedResult geo = (GeoParsedResult) parserdResult;
Log.d("GORIO", "GEO: " + scanResult.getContents());
break;
case TEL:
TelParsedResult tel = (TelParsedResult) parserdResult;
Log.d("GORIO", "TEL: " + scanResult.getContents());
break;
case SMS:
Log.d("GORIO", "SMS: " + scanResult.getContents());
SMSParsedResult sms = (SMSParsedResult) parserdResult;
Log.d("GORIO", "SMS: " + sms.getNumbers());
break;
case CALENDAR:
Log.d("GORIO", "CALENDAR: " + scanResult.getContents());
break;
case ISBN:
ISBNParsedResult isbn = (ISBNParsedResult) parserdResult;
Log.d("GORIO", "ISBN: " + scanResult.getContents());
break;
default:
}
}
你可以把你的內容串上分號的基礎上,讓您的單獨消息 –
分開束值,如果你在那裏找到的電子郵件,然後發送電子郵件其他SMS –
維韋克·米什拉,如果我的身體 – Ges