1、在CaptureActivityHandler类里方法:

public void handleMessage(Message message)

接收对图片解码后的结果,如果界面成功则进入下面分支

case R.id.decode_succeeded:

Log.d(TAG, "Got decode succeeded message");
state = State.SUCCESS;
Bundle bundle = message.getData();
Bitmap barcode = bundle == null ? null :
(Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);
activity.handleDecode((Result) message.obj, barcode);

2、调用CaptureActivity类handleDecode-> private void handleDecodeInternally(Result rawResult, Bitmap barcode)

//格式

TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
formatTextView.setText(rawResult.getBarcodeFormat().toString());

//类型

ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);
TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
typeTextView.setText(resultHandler.getType().toString());

//时间 这个就无所谓了

DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
timeTextView.setText(formattedTime);

那条形码的值如何获得呢? rawResult.getText();即可获得。

进行结果解码结果解析,解析结果例如:

图片+ 条形码的值:978771151622121

格式 EAN_13

类型 ISBN

时间 2011

其中条形码值和类型,格式这三个数据就是使用zxing图片解码最后得到的数据。

3、总结

zxing条形码扫描的工作流程:

1)启动相机,在间隔很短的时间内连续拍照

2)调用图片解码把拍到在图片进行解码

3)当解码出结果时,解码器返回成功结果和数据

4)在界面上显示解码后的数据

更多相关文章

  1. “罗永浩抖音首秀”销售数据的可视化大屏是怎么做出来的呢?
  2. Nginx系列教程(三)| 一文带你读懂Nginx的负载均衡
  3. 不吹不黑!GitHub 上帮助人们学习编码的 12 个资源,错过血亏...
  4. android显示png图片,原来透明的地方都变成黑色的了
  5. Android(安卓)图片文件夹区别
  6. 格式化字符串长度,超出部分显示省略号,区分汉字跟字母
  7. android studio上imageloader初探
  8. Android通过URL获取网络资源
  9. 2011.10.09——— android ImageView放大缩小(2)

随机推荐

  1. Android 模拟HTTP 协议进行表单提交
  2. Eclipse下Android的代码调试
  3. Android 系统(243)---Android进程系列第一
  4. win10通过网线连接树莓派和PC方法(Android
  5. android支持多种屏幕
  6. Android监听网络的变化
  7. android TTS语音播报
  8. 太激动!Android修改全局字体样式,替换整个A
  9. [置顶] Android本地文件管理器思路解析一
  10. 第十一章、Android的线程和线程池