Android zxing扫码处理

发布于:2021-10-14 08:56:37

android:name="com.google.zxing_n.activity.CaptureActivity"
android:screenOrientation="portrait" />

?


public class CaptureActivity extends Activity implements Callback {

public void handleDecode(Result result, Bitmap barcode) {
inactivityTimer.onActivity();
playBeepSoundAndVibrate();
String resultString = result.getText();
String mAccounts = PrefsUtils.readPrefs(getApplicationContext(), Constants.mAccounts);
// 这里获取到扫码结果以及处理
if(result.getText().contains("visitorDetail")){
result= new Result(result.getText()+mAccounts,result.getRawBytes(),result.getResultPoints(),result.getBarcodeFormat());
Log.d("CaptureActivity",result.getText());
}
//FIXME
if (TextUtils.isEmpty(resultString)) {
Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
} else {
Intent resultIntent = new Intent();
Bundle bundle = new Bundle();
resultString = result.getText();
bundle.putString(Constant.INTENT_EXTRA_KEY_QR_SCAN, resultString);
// 不能使用Intent传递大于40kb的bitmap,可以使用一个单例对象存储这个bitmap
// bundle.putParcelable("bitmap", barcode);
// Logger.d("saomiao",resultString);
resultIntent.putExtras(bundle);
this.setResult(RESULT_OK, resultIntent);
}
CaptureActivity.this.finish();
}



}

相关推荐

最新更新

猜你喜欢