Zxing简明教程

本文是Zxing的简明教程,介绍了如何获取依赖并集成到项目中,包括Grandle配置和使用步骤。同时,文章提及了源码学习的重要性,并简单提及时序图和类图在理解Zxing中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何获取依赖?

Grandle依赖:

// https://mvnrepository.com/artifact/com.google.zxing/core
compile group: 'com.google.zxing', name: 'core', version: '3.4.0'

最新地址

如何使用?

  1. 新建一个Zxing的Config类
ZxingConfig config = new ZxingConfig();
  1. 配置参数
        config.setPlayBeep(true);//是否播放扫描声音 默认为true
        config.setShake(true);//是否震动  默认为true
        config.setDecodeBarCode(true);//是否扫描条形码 默认为true
        config.setReactColor(R.color.colorAccent);//设置扫描框四个角的颜色 默认为白色
        config.setFrameLineColor(R.color.colorAccent);//设置扫描框边框颜色 默认无色
        config.setScanLineColor(R.color.colorAccent);//设置扫描线的颜色 默认白色
        config.setFullScreenScan(true);//是否全屏扫描  默认为true  设为false则只会在扫描框中扫描
  1. 启动意图
        Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
        intent.putExtra(Constant.INTENT_ZXING_CONFIG, config);
        startActivityForResult(intent, 1);
  1. 在onActicityResult( )方法中获取结果
String scanResult=data.getStringExtra(Constant.CODED_CONTENT);

源码学习

如果想深入的话,可以继续学习(挖坑…)

时序图

在这里插入图片描述

类图

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值