Android (ICS) NFC Request and response possible - android

I started working on android (ics) nfc applications. Now I have the scenario of using an nfc smartphone an another nfc device which should communicate with each other.
Not a real problem, but I need a kind of Request/Response scenario. Like the nfc smartphone is held in front to the nfc device and sends an key to it via nfc. The device takes the key and starts communicating with an backend system and after that sends a response back to the nfc smartphone. The smartphone gets the response, handles it, smartphone can’t be removed from device and we’re done.
But I really need the response. I did not get this done via the nfc possibilities android ics (beam) is offering.
So therefore my question. Is this somehow possible??
And if yes could somehow explain how? Like using an external library or creating an own?

I think probably you need the NFC to enable the phone's Wifi-direct then do the two-way data transfer.
Or you may need to put the phone close to the device again, then do the beam again.

Related

How have an Android NFC service listening my app?

I have an app built in AppSheet (Google's codeless app building solution). My app can't use my device NFC (Android Smartphone), but it can work with webhooks. I'm trying to figure out if there is a way to have a service running and listening on my device which I could post my data to be transfered through NFC (something like a server listening in localhost:8080). I did not find any solution to this yet.
Do you know any approach like this? Thank you!
There is a System NFC service already running on Android phones that handles all NFC interaction, you communicate to it via the Java/Kotlin API's.
I don't know if Google's AppSheet has a method to interact with the System NFC service many other languages/development platform do have.

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?
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.
This is possible, as explained online here. There is also an API demo in the API demos provided with the SDK that discusses this.
However, keep in mind that NFC has a very small payload size, and you're unlikely to be able to transfer any sizable data using it. NFC should instead be used to quickly setup bluetooth connections, or another form of wireless transfer like WiFi direct, which can then be used to transfer larger amounts of data.

Is it possible to make two-way communication between two devices via NFC?

I am trying to provide an application which sends multiple data between two different devices via NFC. For ex: device1 sends "date" comment and device2 gets the comment via NFC communication and then device2 checks the comment coming from device1. For device2, "date" means date of today and then device2 sends response message (such as 23.05.2013 14:21:45) at the same time. Not only "date" comment, but also the other comments should be used for the communication. For ex: when device1 sends "who are you" comment via NFC, device2 should send "i am Alice's device" at the same time. Is it possible? Can i make such a communication between two different devices at the same time? Thank you for your help.
Sending data via Android Beam in response to a received NDEF message transfered via Android Beam is not possible.
Technically the protocol Android Beam is built upon (LLCP) allows bi-directional data exchange on roughly 240 logical channels at the same time. This capability is just not exposed to Android applications.
You can hope for an API update, but I wouldn't wait for it. A hidden API for this existed in Android 2.3.3 but was later removed for some reason.
As Nils said - via NFC alone, this is not possible due the the limited Android API.
However, I am aware of one way of achieving it by using connection handover. Essentially, the NFC communication is used to send some credentials to the other device that allow the two of them to connect over Bluetooth.
The EasyNFC library claims to achieve this bluetooth functionality. I gave it a try and I think I was able to set up a socket, but never properly tested it. I didn't find it too reliable and I did not want the addition of bluetooth in my application, nor the use of the "Touch-to-beam" UI.

Android Beam - payload transfer from both devices when only one Touch To Beam?

Ok, I watched the Google I/O from 2011 presentation on NFC on peer to peer.
The demo was done on Gingerbread and using the application Sticky Notes found
Now in this demo, both device the onNewIntent() was called at the same time so both devices are trying to share information to one another.
On ICS and above, you have Android Beam..
With Android Beam, you have to touch to trigger the onNewIntent() event that will send the NDef message across.
Now the problem with this is that now to trigger the onNewIntent() on both devices, both user on each device has to "Touch To Beam" at the same time.
Is there a way that when you Touch To Beam on one device, both can have the onNewIntent() to be called?
I am trying to develop an app that will exchange data to each other but for it to work in a nice friendly fashion I need the devices to share the data at the same time once the Touch To Beam has been initiated on one device. I do hope this is possible.
Edit: It looks like this might not be possible to do :(
As far as I can tell, the feature you want is not available over NFC itself. The touch-to-beam/SNEP/NPP transfer is one direction only on Android. The user that clicks his screen will push an NDEF message to the other phone.
What I believe they've done in the video is set up a bluetooth connection with the NDEF message to make the transfer (as you saw in the stickynotes demo). Unfortunately there is no nice API for this.
However, the EasyNFC project promises to be able to allow you to create a bluetooth connection and socket between two phones/applications. Check it out here
I had a try and didn't really like the Touch-to-Beam UI that was still required in the set up of the bluetooth connection. It also didnt really suit my needs, as I wanted to transfer phone to computer and didn't really want to implement NFC P2P and a bluetooth connection.
Did you try this:
Use the Touch to Beam on phone-1 to "PUSH" the data, while on the other (phone-2), use the NDEF_DISCOVERED/TECH_DISCOVERED intent to trigger/start the data capture/reception. I vaguely remember one of the above intents were triggered when a PUSH is done. Although, every transmission requires a "Touch" to start the beaming.
When you think in general, Android should not allow the NFC data transfer in both direction at the same time. Lets think of a scenario where I want to send a thing to my friend with NFC. What is actively open on my friend's phone is not important. I should send this thing even the same app is not open on the receiver side. There may be another app in my friends phone that tries to send another thing to me. When we touch our phones, Android Beam (TM) appears and he data is sent from the phone that is touched.
In you case I think you should disable Android Beam (TM) by setting setNdefPushMessage(null) and do sending both ways using the old way.
https://developer.android.com/preview/api-overview.html
I think it will be available in L!!!
NFC enhancements
Your app can invoke the Android Beam on the user’s device to share data by calling android.nfc.NfcAdapter.invokeBeam(). This avoids the need for the user to manually tap the device against another NFC-capable device to complete the data transfer.

Share tag NFC between two device Android

It is possible?
I state that NFC is enabled on my phone and everything looks correct
I tried with an app called NFC TagWriter by NXP but don't work.
I create a tag with this app and then I tried to listen with other device but don't work, then I installed same app on the other device but don't work.
Please help me or suggested to me another way to do(share tag NFC).
THANKS!
The Android Beam™ feature allows a device to push an NDEF message onto another device by physically tapping the devices together. This interaction provides an easier way to send data than other wireless technologies like Bluetooth, because with NFC, no manual device discovery or pairing is required. The connection is automatically started when two devices come into range. Android Beam is available through a set of NFC APIs, so any application can transmit information between devices. For example, the Contacts, Browser, and YouTube applications use Android Beam to share contacts, web pages, and videos with other devices.
Reference from Developer Documentation
Also check this for Blog , it explains how to communicate between devices.
You can have (indepedent) p2p communication in 2 directions, and enableForegroundNdefPush is deprecated now; please, use setNdefPushMessage

Categories

Resources