Android’s API allows developers to use the NFC capabilities of the host device. This is documented at . This section serves as a summary of these documented possibilities.
3.1 Reader/Writer Mode
Android applications can “read and/or write passive NFC tags and stickers”. This uses NFC in passive mode, with the Android device as the initiator and the tag or sticker as the target. The initiator creates a magnetic alternating field, which it uses to send both power and data (using ASK) to the target. In order to send data in response, the target uses load modulation on the initiator’s magnetic field.
When the Android device’s screen is unlocked and NFC is not disabled in its settings, the device scans for nearby NFC tags. Once a tag is discovered, Android creates an intent (a specific type of object in Android’s API), locates the application best suited to handle the given tag, and dispatches the intent to it.
Per the documentation, “Android has the most support for the NDEF standard, which is defined by the NFC Forum.”
In addition, the API exposes interfaces which allow raw communication with other tag technologies. In these cases, the application must implement its own protocol for communicating with the tag.
The supported technologies are:
NFC-A (ISO 14443-3A),
NFC-B (ISO 14443-3B),
NFC-F (JIS 6319-4),
NFC-V (ISO 15693), and
ISO-DEP (ISO 14443-4).
Optionally, Android devices may support these additional NFC tag technologies:
MiFARE Classic and
API level 9 (Android 2.3 Gingerbread) offers limited tag reading support. The reader/writer mode is supported comprehensively starting from API level 10 (Android 2.3.3 Gingerbread MR1). Android Application Records, which provide a stronger certainty that an NFC tag will be handled by an application, are supported starting from API level 14 (Android 4.0 Ice Cream Sandwich).
3.2 Peer-to-Peer Mode
Android offers functionality called Android Beam, which allows sending an NDEF message from one Android-powered device to another. This uses the active mode of NFC, which means that both devices take turns transmitting both power and data. In the same way as the initiator in NFC’s passive mode, each device in active mode transmits data using ASK modulation.
To send data over Android Beam, the sending application must be running in the foreground of the sending device, and the receiving device must be unlocked and within a close range of the sending device. When these conditions are met, the sending device displays a “Touch to Beam” UI. If the user confirms the action using this UI, then the data is sent.
The payload of Android Beam is transmitted in one way only. The API does not provide any way to receive any payload as a recipient from the recipient.
Android Beam is supported starting from API level 14 (Android 4.0 Ice Cream Sandwich).
NFC is not suitable for the transfer of large files because of its low data rate, combined with the fact that the sender and receiver need to be in close proximity for the whole duration of the transfer. According to , the “sane upper bound” for data transferred using NFC is “about 1 KB (. . .), which can usually be exchanged within 300 ms”.
Since API level 16 (Android 4.1 Jelly Bean), it is possible to transfer large files between Android devices using the Android Beam file transfer API . Android overcomes the speed limitations of NFC by only using it for the initial setup, then silently enabling Bluetooth, temporarily pairing the two devices, and performing the actual file transfer over Bluetooth .
A similar approach to transferring large files was implemented in Sam- sung Galaxy S III, whose S Beam technology uses Wi-Fi Direct instead of Bluetooth to transfer large files after a connection is initiated over NFC .
3.3 Card-Emulation Mode
Android provides an API to implement host-based card emulation . This allows Android applications to talk directly to the NFC reader without involving a secure element.
In this mode, the Android device acts as an NFC target in passive mode. This means that the Android device emulates a possibly unpowered tag and does not create a magnetic field. It only transfers data in response to an initiator (reader) using its magnetic field and load modulation.
Supported are emulated cards “based on the NFC-Forum ISO-DEP specification (based on ISO/IEC 14443-4) and process Application Protocol Data Units (APDUs) as defined in the ISO/IEC 7816-4 specification”. The developer implements their own protocol stack for sending and receiving those APDUs.
Card emulation only works when NFC is enabled and the screen is on. Unlike the reader/writer mode, this can work from the device’s lock screen and does not require any application to be in the foreground.
This functionality is available starting from API level 19 (Android 4.4).
3.4 Missing Features
Even though Android’s API supports all modes of NFC operation, there is no public API for using NFC’s secure element as of Android 6.0, so payment applications need to use host-based card emulation, which provides less protection for sensitive data.
In addition, NFC’s peer-to-peer mode can only be used for Android Beam, which only allows one-shot, simplex data transfers. There is no way to obtain any payload in response to a peer-to-peer request, let alone develop a custom communication protocol, using only the public API.