Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to with one touch two Android devices exchange data via NFC?

I want to create an application to exchange information between 2 devices via NFC.

I know how to make one mobile send information to the other using Android Beam. What I don't know is how two phones could send data to each other with just one touch.

Is this possible? If yes, how?

like image 869
diego.goncalves Avatar asked Oct 01 '22 17:10

diego.goncalves


1 Answers

That depends on what you are trying to achieve and what Android version(s) you are using:

Both devices with Android < 4.0

Both devices can send one NDEF message each with no user interaction required. The messages cannot depend on each other (i.e. it's not possible that one device sends a message and the other one sends an answer to this). You would use a combination of enableForegroundNdefPush() and enableForegroundDispatch() to achieve this.

At least one device with Android < 4.4

Both devices can (theoretically) send one NDEF message per touch, but user interaction is required on both devices (i.e. the user needs to touch the Beam UI). Moreover the Beam UI on both devices needs to be touched pretty much at the same time. Otherwise, the Beam UI on the other device will get interrupted due to the received NDEF message. Thus, this "solution" is not really usable. You would use a combination of setNdefPushMessage*() and enableForegroundDispatch() to achieve this.

Both devices with Android 4.4+

Starting with version 4.4, Android has two new features:

  • NFC reader mode and
  • Host-based Card Emulation (HCE).

When you combine those feature (i.e. you have a HCE on-host card emulation service on one device and put the second device into reader mode), both devices can communicate with each other (real bi-directional communication) using ISO 7816-4 APDUs.

like image 99
Michael Roland Avatar answered Oct 06 '22 01:10

Michael Roland