Near Field Communication (NFC) is a short-distance wireless Communication technology. Generally, the effective Communication distance is less than 4 cm. The NFC operating frequency is 13.65 MHz, and the communication rate is 106 kbit/s to 848 kbit/s.
NFC communication is always composed of an initiator and a receiver (target. Normally, initiator actively sends electromagnetic fields (RF) to provide power to passive receivers (passive target. The basic principle of its work is similar to that of the radio. Because the passive receiver can provide power through the initiator, the target can have very simple forms, such as labels, cards, and sticker forms.
NFC also supports point-to-point communication (peer to peer). At this time, both parties involved in the communication have power support.
Compared with other wireless communication methods, such as Bluetooth, NFC supports much less bandwidth and distance, but it is low in cost. For example, the price tag may be only a few cents, and no matching is required, search for devices, and the communication parties can complete interaction in the near moment.
In Android NFC applications, Android phones are usually the initiators of communication, that is, NFC readers. Android phones can also be used as NFC recipients and support P2P communication from Android 2.3.3.
Android supports NFC mainly in android. nfc and android. nfc. tech packages.
The main categories in the android. nfc package are as follows:
NfcManager can be used to manage all NFC adapters specified in Android devices. However, most Android devices only support one NFC Adapter and can directly use getDefaultAapater to obtain the system-supported adapters.
NfcAdapter is an NFC Adapter object. It can be used to define an Intent so that the system can notify you of the Activity defined when detecting an NFC Tag, and provide methods for registering and sending a forground tag message.
NdefMessage and NdefRecord NDEF are the data formats defined by NFC forum.
A Tag represents a Passive Tag object and can represent a Tag, card, or key chain. When an Android device detects a Tag, it creates a Tag object, places it in the Intent object, and sends it to the corresponding Activity.
Android. nfc. tech defines the read and write operations that can be performed on tags. These classes can be divided into different classes according to their technical types, such as NfcA, NfcB, NfcF, and MifareClassic.
The common Tag is Mifare. The following example uses this Tag as an example to introduce the NFC read/write method.
Excerpted from the mobile app