SDK reference · Android SDK / Android Individual Modules

Phone

The Phone module collects a user's phone number and can confirm phone ownership by sending a one-time password (OTP) via SMS.

For an overview of this module and how it works, see Phone Number Input.

How you use this module depends on your integration pattern. In Patterns 1 and 2, you add the module to a FlowConfig in code as shown on this page. In Pattern 3, you define your modules and configuration in Dashboard as a Flow or Workflow and reference it by ID with startFlow() or startWorkflow() as shown on Run Flows Configured in Dashboard.

Add Phone

  1. Add the module with addPhone() (default config) or addPhone(phone) (custom config):
flowConfigBuilder.addPhone()
// or with a configured instance:
flowConfigBuilder.addPhone(phone)
flowConfigBuilder.addPhone();
// or with a configured instance:
flowConfigBuilder.addPhone(phone);
  1. If your flow also uses the AES (Advanced Electronic Signature) module, add it after Phone. AES requires Phone, along with ID Scan and Selfie Scan, to run first.

Phone ships both a v1 (legacy View) and a v2 (Jetpack Compose) capture screen; the active one depends on your Incode configuration. Contact your Incode representative to enable v2.

Example

The example below builds a Phone module with OTP verification enabled, adds it to the flow, and listens for the result through onAddPhoneCompleted().

val phone = Phone.Builder()
    .setOtpVerificationEnabled(true)
    .build()

val flowConfig = FlowConfig.Builder()
    .addPhone(phone)
    .build()

val onboardingListener = object : OnboardingListener() {
    override fun onAddPhoneCompleted(phoneNumberResult: PhoneNumberResult) {
        // Phone number captured. Process the result.
    }
}

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
Phone phone = new Phone.Builder()
    .setOtpVerificationEnabled(true)
    .build();

FlowConfig flowConfig = new FlowConfig.Builder()
    .addPhone(phone)
    .build();

IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
    @Override
    public void onAddPhoneCompleted(@NonNull PhoneNumberResult phoneNumberResult) {
        // Phone number captured. Process the result.
    }
};

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener);

Configuration Options

Configure the module with Phone.Builder. The table below lists the available options.

Setting Description
setOtpVerificationEnabled(Boolean) If true, shows OTP verification after the user enters a phone number. Defaults to false. In Capture-Only mode, OTP is not activated even when enabled.
setDefaultRegionPrefix(Integer) Sets a dialing prefix that overrides the prefix derived from the carrier or the device's current region. Valid values are up to 4 digits. Do not add a leading +.

For the complete option set, see Phone.Builder in API Reference.

Enable Silent Network Authentication

Silent Network Authentication (SNA) is a phone number verification method that authenticates users through their mobile network using real-time carrier signals. You can enable SNA for the Phone module. SNA is only available in Flows in Dashboard, not Workflows.

  1. Use Android SDK version 5.50.0 or higher. There is no separate -sna variant. No additional Maven repository or credentials are required.
  2. In a Flow in Dashboard, turn on Enable SNA verification in the Phone Number Input module.
  3. Start the onboarding flow using one of the following approaches:
    • startFlow: Specify configurationId inside SessionConfig.Builder().setConfigurationId(), and provide it as sessionConfig to startFlow.

      The Flow configuration drives SNA; no additional code is required.

    • startOnboarding or Sections (where you app builds the FlowConfig: Specify configurationId inside SessionConfig.Builder().setConfigurationId(), and provide it as sessionConfig to startOnboarding or setupOnboardingSession. Then pass the Phone module in your FlowConfig. For Sections, call startOnboardingSection with that Phone module.

      The Flow configuration enables SNA; there is no client-side API to turn it on.

Requirements and fallback behavior
  • SNA requires Android API level 24 or higher. On older devices, the SDK silently falls back to SMS OTP.
  • SNA also falls back to SMS OTP automatically when:
    • The number or carrier is not SNA-covered
    • There is no cellular data path: for example, airplane mode or a VPN-tunneled connection
    • On a transient verification failure
  • The network permissions SNA requires (CHANGE_NETWORK_STATE, ACCESS_WIFI_STATE, CHANGE_WIFI_STATE) are bundled with the SDK and added to your app’s merged manifest automatically; you do not need to declare them. They are normal, install-time permissions, so no user prompt is involved.
  • Optionally declaring the READ_PHONE_STATE runtime permission enables a 2G-network safety check that routes devices on insecure 2G networks straight to SMS OTP. The SDK never requests the permission itself. See the Add Optional Permissions section of Installation.
  • The third-party SDK that powers SNA is bundled inside onboard.aar; no additional Maven repository or credentials are required. If your app ships an open-source/third-party licenses screen, reproduce its license attribution. See Licenses.
  • Bundling adds roughly 150 KB to the onboard artifact. The bundled SDK stays dormant unless the flow configuration enables SNA. It is never loaded on devices below API level 24.
  • Onboarding driven by the Workflows API does not support SNA yet. Phone module configuration in Workflows does not expose an SNA setting. Use a flow configuration (configurationId) for SNA.

Result

Phone delivers a PhoneNumberResult to the onAddPhoneCompleted(PhoneNumberResult) callback on the OnboardingListener. Key fields include:

  • phone: The phone number captured from the user; null when unavailable.
  • Fields inherited from BaseResult:
    • resultCode: The ResultCode for this result.
    • error: When resultCode is ERROR, the Throwable that caused it; otherwise, null.
    • deviceStats: The DeviceStats snapshot of the device state when the result was produced.
    • motionStatus: Device motion assessment during capture. One of the following:
      • UNCLEAR: Motion could not be determined; the default.
      • PASS: Device motion was within acceptable limits.
      • FAIL: Excessive device motion was detected.

Errors surface through OnboardingListener.onError(Throwable). This module does not deliver a module-specific exception subtype.

For all fields, see PhoneNumberResult in API Reference.

Was this page helpful?