NfcEventCallback


interface NfcEventCallback
android.nfc.cardemulation.CardEmulation.NfcEventCallback

Listener for preferred service state changes.

Summary

Public methods
open Unit

This method is called when an AID conflict is detected during an NFC transaction.

open Unit

This method is called when an AID is not routed to any service during an NFC transaction.

open Unit

This method is called when an internal error is reported by the NFC stack.

open Unit

This method is called when the NFC state changes.

open Unit

This method is called when observe mode has been enabled or disabled.

open Unit

This method is called when this package gains or loses preferred Nfc service status, either the Default Wallet Role holder (see android.app.role.RoleManager#ROLE_WALLET) or the preferred service of the foreground activity set with setPreferredService(android.app.Activity,android.content.ComponentName)

open Unit

This method is called when the NFC controller is in card emulation mode and an NFC reader's field is either detected or lost.

Public methods

onAidConflictOccurred

open fun onAidConflictOccurred(aid: String): Unit

This method is called when an AID conflict is detected during an NFC transaction. This can happen when multiple services are registered for the same AID. If your service is registered for this AID you may want to instruct users to bring your app to the foreground and ensure you call setPreferredService(android.app.Activity,android.content.ComponentName) to ensure the transaction is routed to your service.

Parameters
aid String: The AID that is in conflict This value cannot be null.

onAidNotRouted

open fun onAidNotRouted(aid: String): Unit

This method is called when an AID is not routed to any service during an NFC transaction. This can happen when no service is registered for the given AID.

Parameters
aid String: the AID that was not routed This value cannot be null.

onInternalErrorReported

open fun onInternalErrorReported(errorType: Int): Unit

This method is called when an internal error is reported by the NFC stack. No action is required in response to these events as the NFC stack will automatically attempt to recover. These errors are reported for informational purposes only. Note that these errors can be reported when performing various internal NFC operations (such as during device shutdown) and cannot always be explicitly correlated with NFC transaction failures.

Parameters
errorType Int: The type of the internal error Value is android.nfc.cardemulation.CardEmulation#NFC_INTERNAL_ERROR_UNKNOWN, android.nfc.cardemulation.CardEmulation#NFC_INTERNAL_ERROR_NFC_CRASH_RESTART, android.nfc.cardemulation.CardEmulation#NFC_INTERNAL_ERROR_NFC_HARDWARE_ERROR, or android.nfc.cardemulation.CardEmulation#NFC_INTERNAL_ERROR_COMMAND_TIMEOUT

onNfcStateChanged

open fun onNfcStateChanged(state: Int): Unit

This method is called when the NFC state changes.

Parameters
state Int: The new NFC state Value is android.nfc.NfcAdapter#STATE_OFF, android.nfc.NfcAdapter#STATE_TURNING_ON, android.nfc.NfcAdapter#STATE_ON, or android.nfc.NfcAdapter#STATE_TURNING_OFF

See Also

    onObserveModeStateChanged

    open fun onObserveModeStateChanged(isEnabled: Boolean): Unit

    This method is called when observe mode has been enabled or disabled.

    Parameters
    isEnabled Boolean: true if observe mode has been enabled, false if it has been disabled

    onPreferredServiceChanged

    open fun onPreferredServiceChanged(isPreferred: Boolean): Unit

    This method is called when this package gains or loses preferred Nfc service status, either the Default Wallet Role holder (see android.app.role.RoleManager#ROLE_WALLET) or the preferred service of the foreground activity set with setPreferredService(android.app.Activity,android.content.ComponentName)

    Parameters
    isPreferred Boolean: true is this service has become the preferred Nfc service, false if it is no longer the preferred service

    onRemoteFieldChanged

    open fun onRemoteFieldChanged(isDetected: Boolean): Unit

    This method is called when the NFC controller is in card emulation mode and an NFC reader's field is either detected or lost.

    Parameters
    isDetected Boolean: true if an NFC reader is detected, false if it is lost