> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/implement-nfc-wallet/make-payment/implement-contactless-payments/3.-consider-application-start.md).

# 3. Consider application start

## Overview

When your application starts, initialize the NFC Wallet SDK.

Also set the payment experience your digital wallet application supports:

* Support **single-tap** payments.
* Or require **two-tap** payments.

Even if you enable **single-tap**, some transactions can fall back to **two-tap**. See [Single-tap can fall back to two-tap](#single-tap-can-fall-back-to-two-tap).

### Payment application in background

When the digital wallet application is the default payment application (see [Default payment app](/nfc-wallet-sdk-android/help/knowledge-base/control-nfc-payments-on-android.md#default-payment-application)), Android may keep it in the background. This lets it respond quickly to contactless payment APDUs from the POS terminal without recreating the `Application`.

Some devices terminate the default payment application while it is in the background. On these devices, contactless payments can trigger an application cold start. See [Optimize cold starts](#optimize-cold-starts).

## SDK integration

### Update application startup

In `Application.onCreate()`, your application must:

1. Run SDK quick configuration.
2. Set the expected payment experience:
   * `ONE_TAP_ENABLED` to support **single-tap** transactions
   * `TWO_TAP_ALWAYS` to always require authentication after the first tap (always **two-tap** payments)
3. Initialize the SDK in a separate thread.
4. Optional: after initialization succeeds, activate pre-entry. See [Activate pre-entry](#activate-pre-entry).

For steps 1 and 2, see [Initialize the NFC Wallet SDK](/nfc-wallet-sdk-android/get-started/configuration/4.-initialize-the-nfc-wallet-sdk.md).

{% code title="MyApp.java" expandable="true" %}

```java
public class MyApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        
        // Build custom config with no value change (same config since the first SDK init)
        CustomConfiguration customConfig = new CustomConfiguration.Builder()
                .domesticCurrencyCode(978)
                .keyValidityPeriod(60)
                .build();
        
        // 1 - Run quick configuration
        // ... to make sure SDK has the 'Context'
        try {
            SDKInitializer.INSTANCE.configure(this,  customConfig);
        } catch (InternalComponentException e){
            // SDK internal component exception
            // App can ignore this, 
            // and proceed with the actual SDK initialization API and perform the error handling there if Exception is raised
        } catch (Exception e) {
            // Generic exception, this is a safeguard as to prevent any event 
            // that could lead to a crash durign Application startup. 
            // App can ignore this, and proceed with the actual SDK initialization API and perform the error handling there if Exception is raised
        } catch (Throwable e) {
            // this is unlikely to happen, however because this piece of code resides in Application class,
            // in oder to minimized the impact of any error that could implact on the whole application, 
            // we recommend to catch this error. 
            // In case of this error, app shall NOT call SDKInitializer.INSTANCE.initialize()
        }
    
        // 2 - Set the payment experience.
        PaymentExperienceSettings.setPaymentExperience(this, PaymentExperience.ONE_TAP_ENABLED);
        
        // 3 - Initialize the SDK (in separate thread)
        Thread sdkInit = new Thread(new Runnable() {
            @Override
            public void run() {
                SDKInitializer.INSTANCE.initialize(this, customConfig);
            }
        });
        sdkInit.start();
        
        // 4 - Activate pre-entry (optional).
        activatePreEntry();
    }
    
    // Activate pre-entry.
    private void activatePreEntry() {
        final DeviceCVMPreEntryReceiver receiver = new DeviceCVMPreEntryReceiver();
        receiver.init();
        final IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
        registerReceiver(receiver, filter);
    }
    
    

}
```

{% endcode %}

{% hint style="warning" %}

## Single-tap can fall back to two-tap

If you enable `ONE_TAP_ENABLED`, not every transaction is performed as **single-tap**.

Treat **single-tap** as the best-case flow. If the required conditions are not met, NFC Wallet SDK falls back to **two-tap**.

Examples:

* The end user does not tap within the configured validity period after unlocking the device. See `keyValidityPeriod` in [Initialize the NFC Wallet SDK](/nfc-wallet-sdk-android/get-started/configuration/4.-initialize-the-nfc-wallet-sdk.md).
* An LVT transaction without authentication reaches a configured risk threshold. In that case, NFC Wallet SDK requires authentication. See [Define risk management](/nfc-wallet-sdk-android/implement-nfc-wallet/make-payment/implement-contactless-payments/7.-configure-cdcvm-experiences/define-risk-management.md).
  {% endhint %}

### Reduce cold start time

Some devices terminate the default payment application while it is in the background. On these devices, a contactless payment can trigger an application **cold start**.

APDU processing starts immediately after the **cold start**.

The cold start process includes:

* Service binding (around 100–200 milliseconds)
* Completion of `Application.onCreate()`

Minimize work in `Application.onCreate()`. Limit it to NFC Wallet SDK configuration and initialization.

Avoid other operations in the first 0.5 seconds after `Application.onCreate()` starts. Parallel work can delay APDU handling when Android sends APDU commands to the POS terminal.

If needed, delay non-payment work by at least 0.5 seconds after SDK initialization completes.

### Activate pre-entry

Use pre-entry to support **single-tap** payments.

Pre-entry lets the end user authenticate before the payment flow starts.

Authentication happens when the end user unlocks the device with biometrics or device keyguard (PIN, pattern, or password). This enables a payment without an additional verification step.

{% hint style="info" %}
Only one payment is allowed per device unlock when this mode is enabled.
{% endhint %}

```java
private void activatePreEntry() {
    DeviceCVMPreEntryReceiver receiver = new DeviceCVMPreEntryReceiver();
    receiver.init();
    IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
    registerReceiver(receiver, filter);
}
```

{% hint style="warning" %}
Do not add additional intent filters with `DeviceCVMPreEntryReceiver`. This class is designed to act only on the `ACTION_USER_PRESENT` intent.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-android/implement-nfc-wallet/make-payment/implement-contactless-payments/3.-consider-application-start.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
