BcmScanFragment
The Scan Fragment (BcmScanFragment) is the Biocapture SDK's central Fragment and the main player
in the scanning process. It internally manages a camera object and a scan session.
The Scan Fragment is configured using an instance of the BcmGlobalConfig and
the BcmScanConfig. When using the BcmScanActivity, the
configuration is automatically passed to the BcmScanFragment.
Progress is reported to an object implementing the IBcmFlowDelegate interface. Please refer to the usage examples for a high-level overview of the Scan Fragment.
Caveats
Changes made to the SDK global configuration through BcmGlobalConfig are
applied only when a scan session is started. Configure the SDK while no Scan
Fragment (BcmScanFragment) is active to ensure that your configuration is applied to all scan
sessions.
Interface
Kotlin:
open class BcmScanFragment(
/**
* An object enables basic configuration of SDK behavior.
*/
private val globalConfig: BcmGlobalConfig,
/**
* An instance of BcmScanConfig, which may be changed/replaced at will prior to presenting the scan fragment
*/
private val scanConfig: BcmScanConfig = BcmScanConfig(),
/**
* A delegate object for scan flow events
*/
private val flowDelegate: IBcmFlowDelegate? = null
) : ScanFragment(
globalConfig,
scanConfig,
flowDelegate
) {
companion object {
/**
* Information about the required permissions.
*/
fun getRequiredPermissions(): Array<String>? {
return arrayOf(
"android.permission.CAMERA",
"android.permission.FLASHLIGHT",
"android.permission.INTERNET")
}
}
}
Java:
public class BcmScanFragment extends ScanFragment {
/**
* An object enables basic configuration of SDK behavior.
*/
public BcmGlobalConfig globalConfig = new BcmGlobalConfig();
/**
* An instance of BcmScanConfig, which may be changed/replaced at will prior to presenting the scan fragment
*/
public BcmScanConfig scanConfig = new BcmScanConfig();
/**
* A delegate object for scan flow events
*/
public IBcmFlowDelegate flowDelegate = null;
}
Usage
Configuring the Scan Fragment
The Scan Fragment maintains the Biocapture SDK's global configuration using
the BcmGlobalConfig interface. The BcmGlobalConfig object can be set on the
Fragment level, using the globalConfig field.
Additionally, you may change the Scan behavior by providing your own instance of scanConfig or
changing values of the configuration object. For a list of configurable options, please refer to the
class documentation of BcmScanConfig.
Assign a flowDelegate object to receive information about scan progress and the final
result (IBcmFlowDelegate).
Kotlin:
class BcmGlobalConfigOverride : BcmGlobalConfig() {
open fun licenseKey(): String? = ...
}
class BcmScanConfigOverride : BcmScanConfig() {
open fun scanTerminationOption(): ScanTerminationOptions = ...
}
...
val scanFragment: ScanFragment = BcmScanFragment(
BcmGlobalConfigOverride(),
BcmScanConfigOverride(),
this);
Java:
class BcmGlobalConfigOverride extends BcmGlobalConfig {
@Nullable
@Override
public String licenseKey() {
return ...;
}
}
class BcmScanConfigOverride extends BcmScanConfig {
@Nullable
@Override
public ScanTerminationOptions scanTerminationOption() {
return ...;
}
}
...
BcmScanFragment scanFragment=new BcmScanFragment(
new BcmGlobalConfig(),
new BcmScanConfig(),
this);
The settings are applied for all future scan sessions during your app's Scan Activity lifetime.
Creating a Scan Fragment Instance
Once configured, you are ready to scan fingerprints by presenting BcmScanFragment using
the supportFragmentManager of the Activity:
Kotlin:
val scanFragment: BcmScanFragment = BcmScanFragment()
// configuration take place here; see next section
supportFragmentManager.beginTransaction().replace(
R.id.content_frame,
scanFragment)
.addToBackStack("BcmScan")
.commitAllowingStateLoss()
Java:
BcmScanFragment scanFragment=new BcmScanFragment();
// configuration take place here; see next section
getSupportFragmentManager().beginTransaction().replace(
R.id.content_frame,
scanFragment)
.addToBackStack("BcmScan")
.commitAllowingStateLoss()
Scan Session Management
The Scan Fragment by default automatically manages scan sessions, meaning it will start a scan session when presented, stop it when hidden or dismissed, and restart a new scan session after a scan completes (unless dismissed by the Activity).