Android zxing扫码处理

<activity
    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();
    }

}

猜你喜欢

转载自blog.csdn.net/sunshine_0707/article/details/81301827
今日推荐