Accusoft USB Scanner SDK
ScanSession Class Reference

The ScanSession class defines the single object used to control scanners connected to an Android device. More...

Inherits Serializable.

List of all members.

Classes

class  DoAcquireImages
 The DoAcquireImages class extends AsyncTask to perform page scanning in a background thread.
class  DoCalibration
 The DoCalibration class extends AsynTask to perform device calibration in a background thread.
class  DoGetSession
 The DoGetSession class extends AsyncTask to perform ScanSession construction in a background thread.
class  MsgHandler
 The MsgHandler class receives messages intended for the main application thread during calibration or scanning operations.
class  ScanDevice
 The ScanDevice class holds information about a single currently connected scanner. More...
class  SessionMsgHandler
 The SessionMsgHandler class receives messages intended for the main application thread during construction of ScanSession objects.

Public Member Functions

AsyncTask< Void, Void, Void > acquireImages (IScanMessageHandler inHandler)
 Begin scanning pages, and acquiring images of those scanned pages, using a background thread.
void cancelScan ()
 Cancel any scanner operation currently in progress.
void enterSettingsMode () throws ScanException
 Prepare to change the settings of the active scanner by opening it, if necessary.
void exitSettingsMode ()
 Exit mode used to change multiple settings in a row.
ScanDevice getActiveDevice ()
 Get the ScanDevice that is set as the current active scan device.
Integer getBrightness () throws ScanException
 Get the Brightness value for the active scanner.
LinkedHashSet< Integer > getBrightnessValues () throws ScanException
 Get a LinkedHashSet of all possible valid Brightness values for the active scanner.
Integer getContrast () throws ScanException
 Get the Contrast value for the active scanner.
LinkedHashSet< Integer > getContrastValues () throws ScanException
 Get a LinkedHashSet of all possible valid Contrast values for the active scanner.
String getDepth () throws ScanException
 Get the current Pixel Depth (bits per pixel) for the active scanner.
LinkedHashSet< String > getDepthValues () throws ScanException
 Get a LinkedHashSet of all possible valid Pixel Depth values for the active scanner.
List< ScanDevicegetDevices ()
 Obtain a list of the currently connected scan devices for which there are drivers.
String getImageFormat () throws ScanException
 Get the Image Format value for the active scanner.
LinkedHashSet< String > getImageFormatValues () throws ScanException
 Get a LinkedHashSet of all possible valid values for the Image Format used by the scanner.
String getInputSource () throws ScanException
 Get the Input Source value for the active scanner.
LinkedHashSet< String > getInputSourceValues () throws ScanException
 Get a LinkedHashSet of all possible valid values for the Input Source used by the scanner.
Integer getResolution () throws ScanException
 Get the Resolution value for the active scanner.
LinkedHashSet< Integer > getResolutionValues () throws ScanException
 Get a LinkedHashSet of all possible valid values for Resolution for the active scanner.
String getScanArea () throws ScanException
 Get the scan size (area) used by the active scanner.
LinkedHashSet< String > getScanAreaValues () throws ScanException
 Get a LinkedHashSet of all possible valid values for the scan size (area) used by the scanner.
boolean isBrightnessMutable () throws ScanException
 Determine if the Brightness setting's value can be changed.
boolean isContrastMutable () throws ScanException
 Determine if the Contrast setting's value can be changed.
boolean isDepthMutable () throws ScanException
 Determine if the Pixel Depth (bits per pixel) setting's value can be changed.
boolean isImageFormatMutable () throws ScanException
 Determine if the Image Format setting's value can be changed.
boolean isInputSourceMutable () throws ScanException
 Determine if the Input Source setting's value can be changed.
boolean isResolutionMutable () throws ScanException
 Determine if the Resolution setting's value can be changed.
boolean isScanAreaMutable () throws ScanException
 Determine if the Scan Area setting's value can be changed for the active scanner.
AsyncTask< Void, Void, Void > performCalibration (IScanMessageHandler inHandler)
 Perform calibration, if the device supports it, using a background thread.
void registerPermissionIntentReceiver (Context context)
 This function is required to be called whenever the application acquires a new context.
void setActiveDevice (ScanDevice device)
 Set a ScanDevice as the current active scan device.
boolean setBrightness (Integer newVal) throws ScanException
 Set the Brightness value for the active scanner.
boolean setContrast (Integer newVal) throws ScanException
 Set the Contrast value for the active scanner.
boolean setDepth (String newVal) throws ScanException
 Set the number of bits per pixel (Pixel Depth) the scanner will use.
boolean setImageFormat (String newVal) throws ScanException
 Set the Image Format value for the active scanner.
boolean setInputSource (String newVal) throws ScanException
 Set the Input Source the active scanner will use.
boolean setResolution (Integer newVal) throws ScanException
 Set the scan resolution that the active scanner will use.
boolean setScanArea (String newVal) throws ScanException
 Set the scan size (area) the active scanner will use.
boolean supportsCalibration () throws ScanException
 Method that should be used to determine if the scanner supports calibration.
void unregisterPermissionIntentReceiver (Context context)
 This function is required to be called whenever the application's current Context will be lost.

Static Public Member Functions

static AsyncTask< Void, Void,
Void > 
requestSession (Context context, ScanLicense license, ISessionCallback inHandler)
 Asynchronously construct a ScanSession object that is used to access scanners connected to an Android device.

Detailed Description

The ScanSession class defines the single object used to control scanners connected to an Android device.


Member Function Documentation

AsyncTask<Void, Void, Void> acquireImages ( IScanMessageHandler  inHandler)

Begin scanning pages, and acquiring images of those scanned pages, using a background thread.

The images and status information is communicated via callback methods of the supplied handler object.

Parameters:
inHandlerAn object that supports the callback methods defined in the IScanMessageHandler interface.
Returns:
void cancelScan ( )

Cancel any scanner operation currently in progress.

This is an asynchronous operation that purposefully does not synchronize with the other ScanSession operations.

void enterSettingsMode ( ) throws ScanException

Prepare to change the settings of the active scanner by opening it, if necessary.

By using this method to explicitly open the scanner, and keep it open, a performance advantage is gained when changing the values of multiple settings in a row. A counter is maintained, so this method may be called multiple times. Each call to this method must be balanced by a call to exitSettingsMode().

Exceptions:
ScanExceptionIf the active device can not be opened.
void exitSettingsMode ( )

Exit mode used to change multiple settings in a row.

A call to this method must balance a corresponding call to enterSettingsMode().

ScanDevice getActiveDevice ( )

Get the ScanDevice that is set as the current active scan device.

Only one scan device may be active at a time.

Returns:
The ScanDevice that is set as the current active scan device.
Integer getBrightness ( ) throws ScanException

Get the Brightness value for the active scanner.

Returns:
The brightness value.
LinkedHashSet<Integer> getBrightnessValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid Brightness values for the active scanner.

Returns:
A LinkedHashSet of all possible valid values for Brightness.
Integer getContrast ( ) throws ScanException

Get the Contrast value for the active scanner.

Returns:
The contrast value.
LinkedHashSet<Integer> getContrastValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid Contrast values for the active scanner.

Returns:
A LinkedHashSet of all possible valid values for Contrast.
String getDepth ( ) throws ScanException

Get the current Pixel Depth (bits per pixel) for the active scanner.

Returns:
The Pixel Depth value, measured in bits per pixel.
LinkedHashSet<String> getDepthValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid Pixel Depth values for the active scanner.

Returns:
A LinkedHashSet of all possible valid Pixel Depth values, measured in bits per pixel.
List<ScanDevice> getDevices ( )

Obtain a list of the currently connected scan devices for which there are drivers.

Each time that this method is called, the previous list of devices, and the ScanDevice objects contained in it, becomes invalid. It is important to note that scan settings are tied to ScanDevice and will also become invalid.

Returns:
A List of ScanDevice objects that are currently connected to the Android device, and for which there are scan drivers.
String getImageFormat ( ) throws ScanException

Get the Image Format value for the active scanner.

Returns:
The image format.
LinkedHashSet<String> getImageFormatValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid values for the Image Format used by the scanner.

Returns:
A LinkedHashSet of all possible valid values for the scan mode (Image Format) used by the scanner.
String getInputSource ( ) throws ScanException

Get the Input Source value for the active scanner.

Returns:
The Input Source.
LinkedHashSet<String> getInputSourceValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid values for the Input Source used by the scanner.

Returns:
A LinkedHashSet of all possible valid values for the Input Source used by the scanner.
Integer getResolution ( ) throws ScanException

Get the Resolution value for the active scanner.

Returns:
The Resolution value.
LinkedHashSet<Integer> getResolutionValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid values for Resolution for the active scanner.

Returns:
A LinkedHashSet of all possible valid values for Resolution.
String getScanArea ( ) throws ScanException

Get the scan size (area) used by the active scanner.

Returns:
The scan area.
LinkedHashSet<String> getScanAreaValues ( ) throws ScanException

Get a LinkedHashSet of all possible valid values for the scan size (area) used by the scanner.

Returns:
A LinkedHashSet of all possible valid values for the input source used by the scanner.
boolean isBrightnessMutable ( ) throws ScanException

Determine if the Brightness setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isContrastMutable ( ) throws ScanException

Determine if the Contrast setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isDepthMutable ( ) throws ScanException

Determine if the Pixel Depth (bits per pixel) setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isImageFormatMutable ( ) throws ScanException

Determine if the Image Format setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isInputSourceMutable ( ) throws ScanException

Determine if the Input Source setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isResolutionMutable ( ) throws ScanException

Determine if the Resolution setting's value can be changed.

Returns:
True if the setting's value can be changed, False otherwise.
boolean isScanAreaMutable ( ) throws ScanException

Determine if the Scan Area setting's value can be changed for the active scanner.

Returns:
True if the setting's value can be changed, False otherwise.
AsyncTask<Void, Void, Void> performCalibration ( IScanMessageHandler  inHandler)

Perform calibration, if the device supports it, using a background thread.

Support for calibration is determined by calling the supportsCalibration() method. Every scan device which supports calibration must be calibrated at least once after it is connected to a new Android host before it may be used. Devices which require calibration, but have not yet been calibrated will return a DEVICE BUSY error. Status information is communicated via callback methods of the supplied handler object.

Parameters:
inHandlerAn object that supports the callback methods defined in the IScanMessageHandler interface. Note that the onProgress() and onImage() methods are not used during calibration.
Returns:
void registerPermissionIntentReceiver ( Context  context)

This function is required to be called whenever the application acquires a new context.

(Example: inside onResume())

Parameters:
contextThe context that has been changed
static AsyncTask<Void, Void, Void> requestSession ( Context  context,
ScanLicense  license,
ISessionCallback  inHandler 
) [static]

Asynchronously construct a ScanSession object that is used to access scanners connected to an Android device.

All access to the scanners is done through the object returned by this method. Each time that this method is called a new session will be asynchronously created, and the old one will become invalid. This method need only be called once, when the application starts.

Parameters:
contextA Context that will be used to determine the location of data directories and to register an Intent Receiver for USB permissions.
licenseA ScanLicense object created from the license key supplied by Accusoft.
inHandlerAn object implementing the ISessionCallback interface. The onSession() method of this object will be called when the ScanSession has been constructed.
void setActiveDevice ( ScanDevice  device)

Set a ScanDevice as the current active scan device.

Only one scan device may be active at a time.

Parameters:
deviceThe ScanDevice that is set as the current active scan device.
boolean setBrightness ( Integer  newVal) throws ScanException

Set the Brightness value for the active scanner.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new brightness value. It must be a value contained in the Set returned by getBrightnessValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setContrast ( Integer  newVal) throws ScanException

Set the Contrast value for the active scanner.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new contrast setting. It must be a value contained in the LinkedHashSet returned by getContrastValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setDepth ( String  newVal) throws ScanException

Set the number of bits per pixel (Pixel Depth) the scanner will use.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new depth setting. It must be a value contained in the LinkedHashSet returned by getDepthValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setImageFormat ( String  newVal) throws ScanException

Set the Image Format value for the active scanner.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new image format setting. It must be a value contained in the LinkedHashSet returned by getImageFormatValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setInputSource ( String  newVal) throws ScanException

Set the Input Source the active scanner will use.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new Input Source setting. It must be a value contained in the LinkedHashSet returned by getInputSourceValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setResolution ( Integer  newVal) throws ScanException

Set the scan resolution that the active scanner will use.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new resolution setting. It must be a value contained in the LinkedHashSet returned by getResolutionValues().
Returns:
True if this value was set inexactly or if any other settings values were changed as a side effect. False otherwise.
Exceptions:
ScanException
boolean setScanArea ( String  newVal) throws ScanException

Set the scan size (area) the active scanner will use.

When setting any scanner parameter, other parameters maybe changed as a side effect. Use the return value to determine if the values of any other parameters have been changed.

Parameters:
newValis the new scan area setting. It must be a value contained in the LinkedHashSet returned by getScanAreaValues().
Returns:
Always returns False.
Exceptions:
ScanException
boolean supportsCalibration ( ) throws ScanException

Method that should be used to determine if the scanner supports calibration.

If it does, the scanner will need to be calibrated at least once for every host device to which it is connected.

Returns:
True if calibration is supported. False otherwise.
void unregisterPermissionIntentReceiver ( Context  context)

This function is required to be called whenever the application's current Context will be lost.

(Example: inside onPause())

Parameters:
contextThe context that will change