com.google.zxing.client.android.result
Class ResultHandler

java.lang.Object
  extended by com.google.zxing.client.android.result.ResultHandler
Direct Known Subclasses:
AddressBookResultHandler, CalendarResultHandler, EmailAddressResultHandler, GeoResultHandler, ISBNResultHandler, ProductResultHandler, SMSResultHandler, TelResultHandler, TextResultHandler, URIResultHandler, WifiResultHandler

public abstract class ResultHandler
extends java.lang.Object

A base class for the Android-specific barcode handlers. These allow the app to polymorphically suggest the appropriate actions for each data type. This class also contains a bunch of utility methods to take common actions like opening a URL. They could easily be moved into a helper object, but it can't be static because the Activity instance is needed to launch an intent.

Author:
dswitkin@google.com (Daniel Switkin)

Field Summary
static int MAX_BUTTON_COUNT
           
 
Method Summary
 boolean areContentsSecure()
          Some barcode contents are considered secure, and should not be saved to history, copied to the clipboard, or otherwise persisted.
abstract  int getButtonCount()
          Indicates how many buttons the derived class wants shown.
abstract  int getButtonText(int index)
          The text of the nth action button.
 java.lang.CharSequence getDisplayContents()
          Create a possibly styled string for the contents of the current barcode.
abstract  int getDisplayTitle()
          A string describing the kind of barcode that was found, e.g.
 ParsedResult getResult()
           
 ParsedResultType getType()
          A convenience method to get the parsed type.
abstract  void handleButtonPress(int index)
          Execute the action which corresponds to the nth button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BUTTON_COUNT

public static final int MAX_BUTTON_COUNT
See Also:
Constant Field Values
Method Detail

getResult

public ParsedResult getResult()

getButtonCount

public abstract int getButtonCount()
Indicates how many buttons the derived class wants shown.

Returns:
The integer button count.

getButtonText

public abstract int getButtonText(int index)
The text of the nth action button.

Parameters:
index - From 0 to getButtonCount() - 1
Returns:
The button text as a resource ID

handleButtonPress

public abstract void handleButtonPress(int index)
Execute the action which corresponds to the nth button.

Parameters:
index - The button that was clicked.

areContentsSecure

public boolean areContentsSecure()
Some barcode contents are considered secure, and should not be saved to history, copied to the clipboard, or otherwise persisted.

Returns:
If true, do not create any permanent record of these contents.

getDisplayContents

public java.lang.CharSequence getDisplayContents()
Create a possibly styled string for the contents of the current barcode.

Returns:
The text to be displayed.

getDisplayTitle

public abstract int getDisplayTitle()
A string describing the kind of barcode that was found, e.g. "Found contact info".

Returns:
The resource ID of the string.

getType

public final ParsedResultType getType()
A convenience method to get the parsed type. Should not be overridden.

Returns:
The parsed type, e.g. URI or ISBN