4.7. The LazerScanner class
LazerScanner
is the main scanner factory and the core of the library. It is in charge of finding
scanner providers and scanner devices. Most users will let the
ScannerService
handle its own instance of LazerScanner
, but should you need it, you can use its static methods
directly.
- discoverProviders(Context ctx, ProviderDiscoveredCallback cb) void
Discovers scanner providers through service intent and retrieves them through reflection. The providers are cached and do not need to be discovered again unless new entries are expected, it is a costly operation.
- Parameters:
ctx (Context) – a context used to retrieve a
PackageManager
cb (ProviderDiscoveredCallback) – The callback used whenever a provider is found. Automatically wrapped by a
ProviderDiscoveredCallbackProxy
, for which a public overload exists
- getProviderCache() List<String>
- Returns:
the list of provider keys from the current provider cache, including bluetooth ones if available (the cache needs to have been initialized first).
- getLaserScanner(Context ctx, ScannerConnectionHandler handler, ScannerSearchOptions options) void
Search for new laser scanners with available providers. The scanner is provided through a callback. There is a specific callback when no scanner is available.
- Parameters:
ctx (Context) – a context used to retrieve a
PackageManager
handler (ScannerConnectionHandler) – The callback used whenever a scanner is found. Automatically wrapped by a
ScannerConnectionHandlerProxy
, for which a public overload exists.options (ScannerSearchOptions) – The options used to refine the search.
See also
The Callbacks documentation