android studio zbar,Zbar and Zxing in android studio
问题
Hi can anyone teach me how to use zbar/zxing for qr code reader? I have tried many of the sample codes online but none seems to work. Btw im using android studio.
回答1:
I used zxing-android-embedded. Handles the zxing-core for you, automatically opens the camera on a separate thread, and even has docs/examples for custom usage. Also, the authors commit often (every ~2 weeks) and respond fast to issues. It scans QR's and Barcodes out of the box.
Add the permissions for the Camera in your AndroidManifest.xml:
Add this to your build.gradle (app):
repositories {
jcenter()
}
dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
compile 'com.google.zxing:core:3.2.0'
}
Create a callback in your Activity:
private BarcodeCallback callback = new BarcodeCallback() {
@Override
public void barcodeResult(BarcodeResult result) {
// Do something with the scanned QR code.
// result.getText() returns decoded QR code.
fooBar(result.getText());
}
@Override
public void possibleResultPoints(List resultPoints) {
}
};
onCreate()
mBarcodeView = (BarcodeView) findViewById(R.id.barcode_view);
// Choose only one!!!
mBarcodeView.decodeSingle(callback);
// Or
mBarcodeView.decodeContinuous(callback);
onResume()
mBarcodeView.resume();
onPause()
mBarcodeView.pause();
In your Activity's XML layout, add the BarcodeView
android:id="@+id/barcode_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
Hope this helps!
来源:https://stackoverflow.com/questions/31736605/zbar-and-zxing-in-android-studio
android studio zbar,Zbar and Zxing in android studio相关推荐
- zbar android本地图片,ZBar Android扫描本地QR或条形码图像
5 个答案: 答案 0 :(得分:4) 试试这个: Bitmap barcodeBmp = BitmapFactory.decodeResource(getResources(), R.drawabl ...
- android activity 实际,如何整合Zxing条形码扫描器而不安装实际的zxing应用程序(无法解析符号:.android.CaptureActivity)?...
虽然已经得到回答,我觉得对于那些想使用ZXing作为库而不使用ANT这样的自动安装方法的人来说,我觉得这是一个深入的解决方案. ZXing作为开源项目允许(如ZXing网站所述),您将其功能用作项目库 ...
- android zxing作用,Android / ZXing不再有效
我的应用程序使用ZXing帮助程序类IntentIntegrator和IntentResult来使用ZXing条形码扫描程序. 现在我发现ZXing不再提交扫描结果,相关的返回值为空/空. 因此,我更 ...
- Andriod Studio 解决问题 Failed to resolve: com.android.support:appcompat-v7:28.+
Andriod Studio 解决问题 Failed to resolve: com.android.support:appcompat-v7:28.+ 参考文章: (1)Andriod Studio ...
- Android 使用OpenCV的三种方式(Android Studio)
from: http://blog.csdn.net/sbsujjbcy/article/details/49520791 其实最早接触OpenCV是很久很久之前的事了,大概在2013年的5,6月份, ...
- 【Android 逆向】Android 进程注入工具开发 ( Visual Studio 开发 Android NDK 应用 | VS 自带的 Android 平台应用创建与配置 )
文章目录 一.Visual Studio 安装 " 使用 C++ 的移动开发 " 二.Visual Studio 中创建 " 动态共享库(Android) " ...
- 【错误记录】AS 编译报错 ( Android Support plugin 版本太高 | 升级 Android Studio 到最新版本 )
文章目录 一.报错信息 二.解决方案 一.报错信息 从 GitHub 中 Clone 了一份代码 , 编译时报如下错误 ; Download https://services.gradle.org/d ...
- 【Android RTMP】RTMPDumb 源码导入 Android Studio ( 交叉编译 | 配置 CMakeList.txt 构建脚本 )
文章目录 安卓直播推流专栏博客总结 一. RTMP 协议 二. RTMP 协议使用 三. RTMPDump 源码下载 四. RTMPDump 源码交叉编译 五. RTMPDump 源码导入 Andro ...
- android studio device功能,Android Studio 3.0找不到Android Device Monitor
因为自Android Studio 3.0开始弃用Android Device Monitor,Android Developers官网上的原话是: Android Device Monitor is ...
- Android Studio同步失败设置代理,Android Studio如何设置代理?
由于使用Android Studio期间,很多时候都要访问谷歌官方服务器,但是由于一些其他原因,会导致连接不上或者速度很慢,那就需要我们设置一下国内的镜像代理了.下面,让我们一起来看看Android ...
最新文章
- 关于枚举概念的理解以及存在意义
- 从扁鹊医术看华为数据中心智能化运维之道
- Android牟利之道(一)--界面嵌入有米广告
- 具体数学-第2课(成套方法求解递归式)
- iOS开发中,应用内直接跳转到Appstore
- 西点军校的经典法则[转]
- 从想当亿万富翁到职场、创业、爱情、抑郁、学医学武,我的程序人生
- c语言ascii字母比较大小,C语言中,大写字母M的ASCII码值比小写字母m的ASCII码值大。...
- Android APP微信第三方登录踩坑 - 微信开放平台修改应用包名后微信第三方登录失败
- 高动态范围红外图像压缩
- 自己搭建无线音乐服务器,建立自己的音乐库 Aurender ACS10 音乐服务器
- 7-18(查找) 新浪微博热门话题(30 分)
- Power BI时间智能
- 基于昇腾AI异构计算架构CANN的通用目标检测与识别一站式方案初体验
- Bind9源代码分析
- LeetCode刷题记 --- pta 7- 4
- CVPR2018 CartoonGAN 解读
- Problem F. Asperger Syndrome
- 秦九邵算法计算多项式(C语言实现)
- bitmap灵活存储思维