Skip to content

AlphynSDK Class

Main SDK class providing core functionality. All methods are static. Getters throw AlphynException if the SDK is not initialized or the operation fails (getCode() returns codes such as SDK_NOT_INITIALIZED, SCAN_PENDING, INVALID_PARAMETER, OPERATION_FAILED).

initialize(Context context)

  • Description: Initializes the SDK keyless - the recommended mode for production. The app’s attestation identity is the SHA-256 of its signing certificate, which is stable across builds signed with the same key.
  • Parameters: context - Application context (required)
  • Returns: AlphynSDK instance (for call chaining)
  • Throws: IllegalArgumentException if parameters are null or invalid
  • Thread: initialize() returns once setup has finished, so calling it on the main thread delays the app’s first frame. Call it from a background thread, or use initializeAsync. Listener callbacks are delivered on the main thread.

initializeAsync(Context context, InitializeCallback callback)

  • Description: Initializes the SDK keyless, as initialize(Context) does, on a background thread. The recommended way to initialize from Application.onCreate() or any other main-thread code. Available from SDK 1.8.5.
  • Parameters: context - Application context (required); callback - receives the outcome (required)
  • Returns: Immediately, before setup has finished
  • Throws: IllegalArgumentException at the call if a parameter is null
  • Callback: onComplete(Throwable error) runs on the main thread once setup has finished. error is null on success; otherwise it is the exception initialize would have thrown. The run’s INIT_COMPLETE / INIT_FAILED listener events are delivered before it.
AlphynSDK.initializeAsync(this, error -> {
if (error != null) {
Log.e("Byteria", "Initialization failed: " + error.getMessage());
}
});

initialize(Context context, String applicationKey)

  • Description: Initializes the SDK with a development-only debug hash obtained from the Alphyn Portal (App Details → App Info). Do not use in production - a supplied value overrides the app’s attestation hash.
  • Parameters: context - Application context; applicationKey - debug hash (must not be null or empty)
  • Returns: AlphynSDK instance
  • Throws: IllegalArgumentException if parameters are null or invalid

initializeAsync(Context context, String applicationKey, InitializeCallback callback)

  • Description: initializeAsync with the development-only debug hash, as initialize(Context, String) takes it. Do not use in production. Available from SDK 1.8.5.
  • Throws: IllegalArgumentException at the call if a parameter is null or the key is empty

InitializeCallback

  • Description: Single-method interface, void onComplete(Throwable error); a lambda fits it

setInterval(float interval)

  • Description: Sets the background scan interval in minutes (default 0.75 = 45 seconds). Call before initialize for chaining: AlphynSDK.setInterval(1.0f).initialize(context);
  • Returns: AlphynSDK instance

isInitialized()

  • Description: Checks if the SDK has been successfully initialized
  • Returns: boolean - true if initialized, false otherwise
  • Thread: Thread-safe

addSecurityListener(AlphynSecurityListener listener)

  • Description: Adds a security event listener (callbacks are delivered on the main thread)
  • Thread: Thread-safe

removeSecurityListener(AlphynSecurityListener listener)

  • Description: Removes a security event listener
  • Thread: Thread-safe

getScanResult()

  • Returns: String - Latest security scan result summary
  • Throws: AlphynException

getAppHash()

  • Returns: String - The app’s integrity hash (SHA-256 of the signing certificate in keyless mode)
  • Throws: AlphynException

getDeviceId()

  • Returns: String - Persistent unique device identifier
  • Throws: AlphynException

getModules()

  • Returns: String - JSON array of active security modules (e.g. ["ROOT-V1", ...])
  • Throws: AlphynException

getAllRiskFactors()

  • Returns: List<String> - Risk factors the last completed scan found (["DEVICE_CLEAN"] when clean)
  • Throws: AlphynException - SCAN_PENDING until the first scan of the process completes

getLastScanDate()

  • Returns: String - Timestamp of the last scan (e.g. "2025-09-18 12:55:01")
  • Throws: AlphynException

getRejectReasons()

  • Returns: String - The last completed scan’s rejection reasons, one CODE|Description per line; an empty string when the scan found nothing
  • Throws: AlphynException - SCAN_PENDING until the first scan of the process completes

getAllScanResults() / getAllScanResults(Date startDate, Date endDate)

  • Returns: List<String> - Historical scan results, optionally filtered by date range
  • Throws: AlphynException

enableScreenshotProtection(Activity activity) / disableScreenshotProtection(Activity activity) / isScreenshotProtectionEnabled(Activity activity)

  • Description: Toggles/queries screenshot protection (FLAG_SECURE) for the given Activity
  • Returns: boolean - whether the operation succeeded / protection is enabled

enableOverlayProtection(Activity activity) / disableOverlayProtection(Activity activity)

  • Description: Toggles protection against overlay attacks for the given Activity
  • Returns: boolean - whether the operation succeeded

isOverlayProtectionAvailable() / isOverlayProtectionAvailable(Context context)

  • Description: Checks whether overlay protection is available on this device (requires Android 12+ / API 31)
  • Returns: boolean

High-risk actions are verified with signAction, which signs the transaction with a hardware-backed key belonging to an enrolled user and returns a short-lived token your backend validates server-side. See MFA Transaction Signing for the three-call flow, and MFA on Android for the signatures.