androidandroid技术专栏

Google ZXing系列讲解(三)——ZXing 目录结构与

2017-02-26  本文已影响1240人  檀木丁

概要

本篇讲解2个问题

ZXing 结构

本系列涉及的都是Google ZXing Demo, 也就是源码中的android目录。从 Google ZXing系列讲解(一)——导入AS 就提到 ZXing源码中的目录分类,包含内容较多。从Android实际使用角度,会涉及 core, android-core, android-integration, android 四个目录。

/**
 * Utility methods for configuring the Android camera.
 *
 * @author Sean Owen
 */
IntentIntegrator.java
<p>A utility class which helps ease integration with Barcode Scanner via {@link Intent}s. This is a simple
  way to invoke barcode scanning and receive the result, without any need to integrate, modify, or learn the
  project's source code.</p>
 IntentResult.java
 <p>Encapsulates the result of a barcode scan invoked through {@link IntentIntegrator}.</p>

该jar包用于第三方应用通过Intent调用ZXing app。

ZXing Demo目录结构

目录结构图

该Demo实现的功能很多, 扫描条形码,二维码。扫描书籍, 剪切板, 编码, 扫描历史记录,分享,扫描WIFI。

ZXing Android 摄像头启动过程

在介绍ZXing Android Camera启动过程前 ,先来看下扫码总体流程

ZXing扫码整体过程

扫码过程

ZXing Android入口

带UI界面的Android App都有一个入口Activity, 从AndroidManifest.xml中可以查验

<activity android:name=".CaptureActivity"
          ......>
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    ... ...
</activity>

所以,类CaptureActivity就是ZXing Demo的入口Activity, 仔细查看其生命周期函数,发现做了很多工作。

onCreate

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

onResume

CaptureActivity类关系图

Capture类关系图

camera包结构

camera包结构

该package作用是管理camera,包括打开,关闭,配置camere, 闪光灯等。

ZXing Camera具体流程

ZXing Camera打开流程

以上流程图,经过手机 log调试,内容属实! 该图展示,ZXing 打开Camera 扫描 1D/2D 主体流程。

上一篇下一篇

猜你喜欢

热点阅读