public void onPreviewFrame(byte[] data, Camera camera) { Camera.Parameters parameters = camera.getParameters(); Camera.Size size = parameters.getPreviewSize(); Image barcode = new Image(size.width, size.height, "Y800"); barcode.setData(data); int result = mScanner.scanImage(barcode); if (result != 0) { mCamera.cancelAutoFocus(); mCamera.setPreviewCallback(null); mCamera.stopPreview(); mPreviewing = false; SymbolSet syms = mScanner.getResults(); for (Symbol sym : syms) { String symData = sym.getData(); if (!TextUtils.isEmpty(symData)) { Intent dataIntent = new Intent(); dataIntent.putExtra(SCAN_RESULT, symData); dataIntent.putExtra(SCAN_RESULT_TYPE, sym.getType()); setResult(Activity.RESULT_OK, dataIntent); finish(); break; } } } }
public void onPreviewFrame(byte[] data, Camera camera) { Camera.Parameters parameters = camera.getParameters(); Size size = parameters.getPreviewSize(); Image barcode = new Image(size.width, size.height, "Y800"); barcode.setData(data); int result = scanner.scanImage(barcode); String strScanResult = ""; if (result != 0) { previewing = false; mCamera.setPreviewCallback(null); mCamera.stopPreview(); SymbolSet syms = scanner.getResults(); for (Symbol sym : syms) { // scanText.setText("barcode result " + sym.getData()); strScanResult += sym.getData(); barcodeScanned = true; } Intent myIntent = new Intent(MainActivity.this, ValidateBarCodeResult.class); myIntent.putExtra("barcode_result", strScanResult); startActivity(myIntent); } }
public void onPreviewFrame(byte[] data, Camera camera) { Camera.Parameters parameters = camera.getParameters(); Camera.Size size = parameters.getPreviewSize(); Image barcode = new Image(size.width, size.height, "Y800"); barcode.setData(data); int result = scanner.scanImage(barcode); if (result != 0) { previewing = false; mCamera.setPreviewCallback(null); mCamera.stopPreview(); SymbolSet syms = scanner.getResults(); playBeepSoundAndVibrate(); // 播放声音和振动代表成功获取二维码 for (Symbol sym : syms) { // 将扫描后的信息返回 String resultStr = sym.getData(); Log.i(TAG, "resultStr: " + resultStr); if (resultStr.isEmpty() || !resultStr.substring(0, 7).equalsIgnoreCase("http://")) { // Message msg = new Message(); // msg.what = MSG_SCANRESULT_NONE; // myHandler.sendMessage(msg); MyApp.showToast(mContext, "二维码信息内容不符合房产投票项目的要求, 请联系管理人员!"); Intent intent = new Intent(); intent.putExtra("downloadfile", ""); setResult(RESULT_OK, intent); finish(); } else { downLoadDBFile(resultStr); // mLoginSqldb.close(); // mVoteSqldb.close(); Intent intent = new Intent(); intent.putExtra("downloadfile", mDownloadfile); setResult(RESULT_OK, intent); finish(); } } } }
public void onPreviewFrame(byte[] data, Camera camera) { Camera.Parameters parameters = camera.getParameters(); Size size = parameters.getPreviewSize(); Image barcode = new Image(size.width, size.height, "Y800"); barcode.setData(data); int result = scanner.scanImage(barcode); if (result != 0) { previewing = false; mCamera.setPreviewCallback(null); // mCamera.stopPreview(); SymbolSet syms = scanner.getResults(); for (Symbol sym : syms) { scanText.setText("barcode" + sym.getData()); barcodeScanned = true; launchIntent(syms); } } }