Build with Android NFC

United States
Canada
Europe

Using Android API level 19 onwards, you can build solutions that use Android Near Field Communication (NFC) to read and write payloads of data between a tag and a Clover device.

The following Clover devices support both the NFC reader and writer modes:

  • Clover Station 2018 with display printer
  • Clover Mini 2
  • Clover Flex

Clover device guidelines

In this section, we introduce you to required considerations for building with Android NFC on Clover devices:

  • Conserve power: To account for thermal and power considerations on Clover devices, do not keep NFC enabled for your app at all times. We highly recommend that you enable NFC for your app only when a tag is detected. If no tag is detected for 10 minutes, NFC is disabled automatically. At this point, you can enable NFC again by moving your app to the foreground.
  • Show NFC states: Provide an indication of the current NFC state (for instance, a spinner) by implementing a broadcast receiver for the ACTION_ADAPTER_STATE_CHANGED action.
  • Supported signal and tag modes: The following table highlights the different signal and tag modes supported by Clover devices:
Signal modeTag mode
NFC-A, NFC-B, NFC-FT1T, T2T, T3T, T4T

Use the NfcAdapter class

In this section, we discuss guidelines for using the Android NfcAdapter class in your app.

Enable the NFC reader

The NFC antenna is enabled only when your app is in the foreground. In the foreground activity, your app must call the following methods of the NfcAdapter class:

  • enableForegroundDispatch() when onResume() is called
  • disableForegroundDispatch() when onPause() is called
    If a window is added over an activity, both the NFC reader and writer modes are disabled.
    Clover devices provide support for 3 NFC states defined by the NfcAdapter class:
StateDescription
STATE_ONThe NFC field is enabled on the Clover device.
STATE_TURNING_ONThe NFC field is being initialized. Your app can show the current NFC state by implementing a broadcast receiver for the ACTION_ADAPTER_STATE_CHANGED action.
STATE_OFFNFC is not supported by the Clover device.

📘

NOTE

Clover devices do not support the STATE_TURNING_OFF NFC state of the NfcAdapter class.

Receive notifications

To receive notifications about tags, register for the following intents:

ACTION_NDEF_DISCOVERED
ACTION_TAG_DISCOVERED
ACTION_TECH_DISCOVERED

Security limitations

To maintain security, Clover does not support Android Beam and any related callbacks. The following methods of the NfcAdapter class are not supported:

enableForegroundNdefPush()
enableReaderMode()
invokeBeam()
setBeamPushUris()
setBeamPushUrisCallback()
setNdefPushMessage()
setNdefPushMessageCallback()
setOnNdefPushCompleteCallback()

📘

NOTE

The Application ID of an NFC device or tag is used by the Android system to identify a Host-based card emulation (HCE) service to communicate with. For more information on HCE services and AIDs, see the Android Developer documentation on host-based card emulation.

All non-payment AIDs are automatically allowed by Clover. Payment AIDs begin with 0xA00000 and are blocked by Clover.

For additional information on Android NFC specifications and capabilities, see the Android Developer documentation on NFC.