public class

ScannerFragment

extends Fragment
implements TextureView.SurfaceTextureListener
java.lang.Object
   ↳ android.app.Fragment
     ↳ com.vuzix.sdk.barcode.ScannerFragment

Class Overview

ScannerFragment is an easy way to add barcode scanning functionality to your app. To use, follow these steps:

  1. Obtain CAMERA permissions. ScannerFragment makes no attempt to request permissions on its own. Failure to obtain CAMERA permissions will cause scanning to fail.
  2. Instantiate an instance of ScannerFragment.
  3. Register a listener to receive barcode scanning results.
  4. Use FragmentManager to add the fragment to your activity. For best results, add fragment should be added within a 16x9 container.

Summary

Nested Classes
interface ScannerFragment.Listener Interface for those who want to be notified when a barcode is identified. 
interface ScannerFragment.Listener2  
Constants
String ARG_BARCODE2_TYPES A string array argument for specifying barcode types to scan for.
String ARG_BARCODE_TYPES This constant is deprecated. As of Scanner 2
String ARG_LICENSE_KEY This constant is deprecated. As of Scanner 2
String ARG_SCANNING_RECT A parcelable argument for specifying the scanning rect.
String ARG_ZOOM_IN_MODE A boolean argument for barcode run in zoom mode.
[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
Public Constructors
ScannerFragment()
Public Methods
void onCreate(Bundle savedInstanceState)
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
void onStart()
void onStop()
void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
boolean onSurfaceTextureDestroyed(SurfaceTexture surface)
void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
void onSurfaceTextureUpdated(SurfaceTexture surface)
void setListener(ScannerFragment.Listener listener)
This method is deprecated. As of Scanner 2
void setListener2(ScannerFragment.Listener2 listener)
Register a callback to be invoked when a barcode is located or an error occurs.
[Expand]
Inherited Methods
From class android.app.Fragment
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.view.View.OnCreateContextMenuListener
From interface android.view.TextureView.SurfaceTextureListener
From interface android.content.ComponentCallbacks

Constants

public static final String ARG_BARCODE2_TYPES

A string array argument for specifying barcode types to scan for. Each string should be the name() of a BarcodeType2. For example:

arguments.putStringArray(ScannerFragment.ARG_BARCODE2_TYPES, new String[] {BarcodeType2.QR.name(), BarcodeType2.QR_MICRO.name()});

Constant Value: "barcode2_types"

public static final String ARG_BARCODE_TYPES

This constant is deprecated.
As of Scanner 2

A string array argument for specifying barcode types to scan for. Each string should be the name() of a BarcodeType. For example:

arguments.putStringArray(ScannerFragment.ARG_BARCODE_TYPES, new String[] {BarcodeType.QR.name(), BarcodeType.QR_MICRO.name()});

Constant Value: "barcode_types"

public static final String ARG_LICENSE_KEY

This constant is deprecated.
As of Scanner 2

A string argument for specifying a custom license key.

Constant Value: "license_key"

public static final String ARG_SCANNING_RECT

A parcelable argument for specifying the scanning rect. For example:

arguments.putParcelable(ScannerFragment.ARG_SCANNING_RECT, new ScanningRect(.5f, .5f));

Constant Value: "scanning_rect"

public static final String ARG_ZOOM_IN_MODE

A boolean argument for barcode run in zoom mode. For example:

arguments.putBoolean(ScannerFragment.ARG_ZOOM_MODE, true);

Constant Value: "zoom_in_mode"

Public Constructors

public ScannerFragment ()

Public Methods

public void onCreate (Bundle savedInstanceState)

Parameters
savedInstanceState Bundle

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Parameters
inflater LayoutInflater
container ViewGroup
savedInstanceState Bundle
Returns
View

public void onStart ()

public void onStop ()

public void onSurfaceTextureAvailable (SurfaceTexture surface, int width, int height)

Parameters
surface SurfaceTexture
width int
height int

public boolean onSurfaceTextureDestroyed (SurfaceTexture surface)

Parameters
surface SurfaceTexture
Returns
boolean

public void onSurfaceTextureSizeChanged (SurfaceTexture surface, int width, int height)

Parameters
surface SurfaceTexture
width int
height int

public void onSurfaceTextureUpdated (SurfaceTexture surface)

Parameters
surface SurfaceTexture

public void setListener (ScannerFragment.Listener listener)

This method is deprecated.
As of Scanner 2

Register a callback to be invoked when a barcode is located or an error occurs. To remove yourself as a listener, set the listener to null.

Parameters
listener ScannerFragment.Listener: a ScannerFragment.Listener

public void setListener2 (ScannerFragment.Listener2 listener)

Register a callback to be invoked when a barcode is located or an error occurs. To remove yourself as a listener, set the listener to null.

Parameters
listener ScannerFragment.Listener2: a ScannerFragment.Listener2