I am trying to send NFC data from one Android device to another. I was able to do it successfully using the 'Touch to Beam' functionality. But I would like the data transfer to take place automatically as soon as both the devices are together.
I saw this question answered in StackOverflow multiple times. Unfortunately, while some say its not possible to send NFC data from one Android device to another this way, some others suggest to try "foreground-dispatching" (which the official documents say is now deprecated). I wasn't successful with "foreground dispatching" though I am not entirely sure if its due to my mistake. Almost all the questions were answered 1 year back, so I was wondering if Google changed something to achieve this. Both my devices are on Android 4.0 or later, but not 4.4.
When using NFC peer-to-peer communication (aka Android Beam) between two Android (4.0+) devices, there is no way to avoid the Beam UI. So it is not possible to transfer data without the "Touch to Beam".
Before Android Beam (effectively Android 2.3.3-2.3.7), this was possible through foreground NDEF push (which is now (a) deprecated and (b) on Android 4.0+ implemented through Beam). In that case NDEF messages where immediately transfered without the "Push to Beam" window.
Only starting with Android 4.4, there is the possibility to communicate between two Android devices over NFC without the Beam UI (actually without using Android Beam and peer-to-peer mode at all): If both devices are 4.4+, one device can use Android HCE to emulate a contactless smartcard and one device can use the reader-mode API (this only works with the reader-mode API introduced in 4.4, so both devices need to be 4.4+) to communicate with the emulated smartcard.
来源:https://stackoverflow.com/questions/23085990/is-it-possible-to-transfer-nfc-data-from-one-android-device-to-another-without-t