NfcEventCallback
interface NfcEventCallback
android.nfc.cardemulation.CardEmulation.NfcEventCallback |
Callback interface for NFC-related events. These callbacks will be called when registered with registerNfcEventCallback(java.util.concurrent.Executor,android.nfc.cardemulation.CardEmulation.NfcEventCallback)
and while the registered caller is still alive. When you are done listening to the callbacks, you should unregister it with unregisterNfcEventCallback(android.nfc.cardemulation.CardEmulation.NfcEventCallback)
.
Summary
Public methods | |
---|---|
open Unit |
onAidConflictOccurred(aid: String) This method is called when an AID conflict is detected during an NFC transaction. |
open Unit |
onAidNotRouted(aid: String) This method is called when an AID is not routed to any service during an NFC transaction. |
open Unit |
onInternalErrorReported(errorType: Int) This method is called when an internal error is reported by the NFC stack. |
open Unit |
onNfcStateChanged(state: Int) This method is called when the NFC adapter state changes. |
open Unit |
onObserveModeStateChanged(isEnabled: Boolean) This method is called when observe mode has been enabled or disabled. |
open Unit |
onPreferredServiceChanged(isPreferred: Boolean) This method is called when this package gains or loses preferred NFC service status. |
open Unit |
onRemoteFieldChanged(isDetected: Boolean) 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.
onNfcStateChanged
open fun onNfcStateChanged(state: Int): Unit
This method is called when the NFC adapter state changes.
Parameters | |
---|---|
state |
Int: The new NFC adapter 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 |
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. This can happen by way of either it becoming 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 |