Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes
com.google.zxing.IntentIntegrator Class Reference

List of all members.

Static Public Member Functions

static AlertDialog initiateScan (Activity activity)
static AlertDialog initiateScan (Activity activity, int stringTitle, int stringMessage, int stringButtonYes, int stringButtonNo)
static AlertDialog initiateScan (Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo)
static AlertDialog initiateScan (Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, CharSequence stringDesiredBarcodeFormats)
static IntentResult parseActivityResult (int requestCode, int resultCode, Intent intent)
static void shareText (Activity activity, CharSequence text)
static void shareText (Activity activity, CharSequence text, int stringTitle, int stringMessage, int stringButtonYes, int stringButtonNo)
static void shareText (Activity activity, CharSequence text, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo)

Static Public Attributes

static final String ALL_CODE_TYPES = null
static final String DEFAULT_MESSAGE = "This application requires Barcode Scanner. Would you like to install it?"
static final String DEFAULT_NO = "No"
static final String DEFAULT_TITLE = "Install Barcode Scanner?"
static final String DEFAULT_YES = "Yes"
static final String ONE_D_CODE_TYPES = ",CODE_39,CODE_93,CODE_128"
static final String PRODUCT_CODE_TYPES = "UPC_A,UPC_E,EAN_8,EAN_13"
static final String QR_CODE_TYPES = "QR_CODE"
static final int REQUEST_CODE = 0x0ba7c0de

Private Member Functions

 IntentIntegrator ()

Static Private Member Functions

static AlertDialog showDownloadDialog (final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo)

Static Private Attributes

static final String PACKAGE = "com.google.zxing.client.android"

Detailed Description

A utility class which helps ease integration with Barcode Scanner via Intents. 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.

Initiating a barcode scan

Integration is essentially as easy as calling initiateScan(Activity) and waiting for the result in your app.

It does require that the Barcode Scanner application is installed. The initiateScan(Activity) method will prompt the user to download the application, if needed.

There are a few steps to using this integration. First, your Activity must implement the method Activity#onActivityResult(int, int, Intent) and include a line of code like this:

 
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
   if (scanResult != null) {
     // handle scan result
   }
   // else continue with any other code you need in the method
   ...
 }

This is where you will handle a scan result. Second, just call this in response to a user action somewhere to begin the scan process:

 
 IntentIntegrator.initiateScan(yourActivity); 

You can use initiateScan(Activity, CharSequence, CharSequence, CharSequence, CharSequence) or initiateScan(Activity, int, int, int, int) to customize the download prompt with different text labels.

Note that initiateScan(Activity) returns an AlertDialog which is non-null if the user was prompted to download the application. This lets the calling app potentially manage the dialog. In particular, ideally, the app dismisses the dialog if it's still active in its Activity#onPause() method.

Sharing text via barcode

To share text, encoded as a QR Code on-screen, similarly, see shareText(Activity, CharSequence).

Some code, particularly download integration, was contributed from the Anobiit application.

Author:
Sean Owen
Fred Lin
Isaac Potoczny-Jones
Brad Drehmer
gcstang

Definition at line 78 of file IntentIntegrator.java.


Constructor & Destructor Documentation

Definition at line 91 of file IntentIntegrator.java.


Member Function Documentation

static AlertDialog com.google.zxing.IntentIntegrator.initiateScan ( Activity  activity) [inline, static]

See initiateScan(Activity, CharSequence, CharSequence, CharSequence, CharSequence) -- same, but uses default English labels.

Definition at line 97 of file IntentIntegrator.java.

static AlertDialog com.google.zxing.IntentIntegrator.initiateScan ( Activity  activity,
int  stringTitle,
int  stringMessage,
int  stringButtonYes,
int  stringButtonNo 
) [inline, static]

See initiateScan(Activity, CharSequence, CharSequence, CharSequence, CharSequence) -- same, but takes string IDs which refer to the Activity's resource bundle entries.

Definition at line 105 of file IntentIntegrator.java.

static AlertDialog com.google.zxing.IntentIntegrator.initiateScan ( Activity  activity,
CharSequence  stringTitle,
CharSequence  stringMessage,
CharSequence  stringButtonYes,
CharSequence  stringButtonNo 
) [inline, static]

See initiateScan(Activity, CharSequence, CharSequence, CharSequence, CharSequence, CharSequence) -- same, but scans for all supported barcode types.

Parameters:
stringTitletitle of dialog prompting user to download Barcode Scanner
stringMessagetext of dialog prompting user to download Barcode Scanner
stringButtonYestext of button user clicks when agreeing to download Barcode Scanner (e.g. "Yes")
stringButtonNotext of button user clicks when declining to download Barcode Scanner (e.g. "No")
Returns:
an AlertDialog if the user was prompted to download the app, null otherwise

Definition at line 128 of file IntentIntegrator.java.

static AlertDialog com.google.zxing.IntentIntegrator.initiateScan ( Activity  activity,
CharSequence  stringTitle,
CharSequence  stringMessage,
CharSequence  stringButtonYes,
CharSequence  stringButtonNo,
CharSequence  stringDesiredBarcodeFormats 
) [inline, static]

Invokes scanning.

Parameters:
stringTitletitle of dialog prompting user to download Barcode Scanner
stringMessagetext of dialog prompting user to download Barcode Scanner
stringButtonYestext of button user clicks when agreeing to download Barcode Scanner (e.g. "Yes")
stringButtonNotext of button user clicks when declining to download Barcode Scanner (e.g. "No")
stringDesiredBarcodeFormatsa comma separated list of codes you would like to scan for.
Returns:
an AlertDialog if the user was prompted to download the app, null otherwise
Exceptions:
InterruptedExceptionif timeout expires before a scan completes

Definition at line 155 of file IntentIntegrator.java.

static IntentResult com.google.zxing.IntentIntegrator.parseActivityResult ( int  requestCode,
int  resultCode,
Intent  intent 
) [inline, static]

Call this from your Activity's Activity#onActivityResult(int, int, Intent) method.

Returns:
null if the event handled here was not related to this class, or else an IntentResult containing the result of the scan. If the user cancelled scanning, the fields will be null.

Definition at line 206 of file IntentIntegrator.java.

static void com.google.zxing.IntentIntegrator.shareText ( Activity  activity,
CharSequence  text 
) [inline, static]

See shareText(Activity, CharSequence, CharSequence, CharSequence, CharSequence, CharSequence) -- same, but uses default English labels.

Definition at line 222 of file IntentIntegrator.java.

static void com.google.zxing.IntentIntegrator.shareText ( Activity  activity,
CharSequence  text,
int  stringTitle,
int  stringMessage,
int  stringButtonYes,
int  stringButtonNo 
) [inline, static]

See shareText(Activity, CharSequence, CharSequence, CharSequence, CharSequence, CharSequence) -- same, but takes string IDs which refer to the Activity's resource bundle entries.

Definition at line 229 of file IntentIntegrator.java.

static void com.google.zxing.IntentIntegrator.shareText ( Activity  activity,
CharSequence  text,
CharSequence  stringTitle,
CharSequence  stringMessage,
CharSequence  stringButtonYes,
CharSequence  stringButtonNo 
) [inline, static]

Shares the given text by encoding it as a barcode, such that another user can scan the text off the screen of the device.

Parameters:
textthe text string to encode as a barcode
stringTitletitle of dialog prompting user to download Barcode Scanner
stringMessagetext of dialog prompting user to download Barcode Scanner
stringButtonYestext of button user clicks when agreeing to download Barcode Scanner (e.g. "Yes")
stringButtonNotext of button user clicks when declining to download Barcode Scanner (e.g. "No")

Definition at line 254 of file IntentIntegrator.java.

static AlertDialog com.google.zxing.IntentIntegrator.showDownloadDialog ( final Activity  activity,
CharSequence  stringTitle,
CharSequence  stringMessage,
CharSequence  stringButtonYes,
CharSequence  stringButtonNo 
) [inline, static, private]

Definition at line 176 of file IntentIntegrator.java.


Member Data Documentation

Definition at line 90 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.DEFAULT_MESSAGE = "This application requires Barcode Scanner. Would you like to install it?" [static]

Definition at line 81 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.DEFAULT_NO = "No" [static]

Definition at line 84 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.DEFAULT_TITLE = "Install Barcode Scanner?" [static]

Definition at line 80 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.DEFAULT_YES = "Yes" [static]

Definition at line 83 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.ONE_D_CODE_TYPES = ",CODE_39,CODE_93,CODE_128" [static]

Definition at line 88 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.PACKAGE = "com.google.zxing.client.android" [static, private]

Definition at line 85 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.PRODUCT_CODE_TYPES = "UPC_A,UPC_E,EAN_8,EAN_13" [static]

Definition at line 87 of file IntentIntegrator.java.

final String com.google.zxing.IntentIntegrator.QR_CODE_TYPES = "QR_CODE" [static]

Definition at line 89 of file IntentIntegrator.java.

final int com.google.zxing.IntentIntegrator.REQUEST_CODE = 0x0ba7c0de [static]

Definition at line 79 of file IntentIntegrator.java.


The documentation for this class was generated from the following file:


android_extras
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 20:13:19