Build with Android NFC (support ended July 2023)
IMPORTANT—Support ended for Android NFC feature from July 2023
With the launch of the third generation of Clover Flex and Mini devices, we no longer support the Android NFC (Near Field Communication) feature.
- In the third generation Clover devices, you can use alternatives to the Android NFC feature, such as external USB NFC readers.
- In earlier Clover devices, such as Clover Station 2018, Mini2, Flex1, and Flex2, you can still use Android NFC; however, we do not actively support this feature.
Android API level: Using Android API level 19 onwards, you can build NFC solutions to read and write data payloads between a tag and a Clover device.
Clover devices: NFC reader and writer modes are available in the following devices:
- Clover Station 2018 with display printer
- Clover Mini 2
- Clover Flex
Clover device guidelines
The required considerations for building with Android NFC on Clover devices are:
- Conserve power: To account for thermal and power considerations on Clover devices, do not enable NFC for your app at all times. We recommend enabling NFC for your app only when a tag is detected. If no tag is detected for 10 minutes, NFC is automatically turned off. At this point, you can enable NFC again by moving your app to the foreground.
- Show NFC states: Indicates the current NFC state, for instance, with a spinner, by implementing a broadcast receiver for the
ACTION_ADAPTER_STATE_CHANGED
action. - Supported signal and tag modes: Different signal and tag modes supported by Clover devices:
Signal mode | Tag mode |
---|---|
NFC-A, NFC-B, NFC-F | T1T, T2T, T3T, T4T |
Use the NfcAdapter class
This section provides 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()
whenonResume()
is calleddisableForegroundDispatch()
whenonPause()
is called
If a window is added over an activity, both the NFC reader and writer modes are disabled.
Clover devices support three NFC states defined by theNfcAdapter
class:
State | Description |
---|---|
STATE_ON | NFC field is enabled on the Clover device. |
STATE_TURNING_ON | 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_OFF | NFC is not supported by the Clover device. |
NOTE
Clover devices do not support the
STATE_TURNING_OFF
NFC state of theNfcAdapter
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()
Communication with HCE
The Android system uses the Application ID (AIDs) of an NFC device or tag to identify a Host-based card emulation (HCE) service with which to communicate. Clover automatically lets all non-payment AIDs but blocks Payment AIDs that start with 0xA00000.
For more information on:
- HCE services and AIDs, see the Android Developer documentation on host-based card emulation
- Android NFC specifications and capabilities, see the Android Developer documentation on NFC
Updated 3 months ago