I found many weak points of Android NFC:
ndef.connect()
cannot work for NFC phone itself, only for tag. It's no way to check the connection status when other phone close to the back.
NDEF cannot interactively send/receive in two way. On the device, tap the screen to raise a message send, and then disconnected, no way to get back data immediately.
NFC api does NOT support card mode. This is so weakness point. There's so many situations need the Phone act as RFID card. Among of them, sometimes no need security element. Once the UID available, server-end can do authentication and rest of things.
I am asking for how to check the connection status after NDEF message has been sent or received complete ?
You can register your app's activity to receive a callback when NDEF push via Android Beam is completed using NfcAdapter.setOnNdefPushCompleteCallback().
Related
I want to make an application is via WiFi would send and receive data without sending them to a specific recipient. I explained to the example of a simple chat: The user sends a message via WiFi, but without a specific destination. As a result, his report available to all users nearby. Similarly other users can receive and send messages. I also want to realize the function of repeater, where each user's device not only receives a message from the other devices, and retransmits them to others allowing increase the coverage area of WiFi connection.
But at the moment it is not possible to send data without a specific recipient. The same WiFi Direct necessarily require pairing before data transfer. Can not specify that the recipient is unknown.
Recently I heard the news about the technology WiFi Aware, which involves greater interaction between WiFI devices. Please reply, WiFi Aware allows to do what I described above? Namely - the transfer of data and we will without a clear indication of the recipient and the need to do additional work (eg preliminary pairing between devices).
If WiFi Aware allows to do what I described - when it is expected to release its API? In particular, for Android devices. And if not - you can tell me how to implement what I need? And in general - it is technically possible?
Thank you for your time and sorry for my bad English.
You should try to look into nsd via wifi-direct. This Network Service discovery via Wifi-Direct. What this helps you to achieve is broadcast information to all listening devices.
On the device which wants to convey the information you addLocalService and on the other devices you should discoverServices. In the ServiceInfo object you can the pass the information you want to communicate to the other devices who are listening for services. Please try to study from the link attached above.
I am not very sure about how repeater will work with this.
I want to start android programming to be able to transfer data between a NFC enabled smartphone and a custom device, but I am not able to find clear information about a few things
For example, my custom device has to be able to send data to the smartphone as well as receive from it. But from what I have read it is not currently possible for two way communication using NFC
How to send data between two devices using NFC in android?
or the more recent,
NFC enabled phone act as a NFC tag
But the Android developers website itself says that we can use Beam to perform peer to peer communication between two android phones, so two way communication should be possible shouldn't it?
Android Beam allows simple peer-to-peer data exchange between two
Android-powered devices. The application that wants to beam data to
another device must be in the foreground and the device receiving the
data must not be locked. When the beaming device comes in close enough
contact with a receiving device, the beaming device displays the
"Touch to Beam" UI. The user can then choose whether or not to beam
the message to the receiving device.
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#p2p
Secondly, can I use an android NFC phone as a tag writer (instead of just a reader)? That is, just send data to my custom device (or a passive NFC tag)?
The keyword in "simple peer-to-peer data exchange" is simple. Currently (Android 4.2), apps cannot do 2-way communication over Beam. However, a custom device can send multiple messages over Beam. All of these will be received by the Android device without problems, but the Android app can only send one message. You can trick the Android device, however, by resetting the RF field in your custom device. It will appear to the Android device as if a new device has appeared and it will show the "Touch to Beam" UI again.
Android NFC devices can act as both tag reader and writer.
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.
I was reading about Near Field Communication on Android and was wondering if there is any way to retrieve information from one phone by another. So this can be done in two ways :
Phone(Retriever) connects via NFC to another Phone(Client). The Client does not have any special application installed, but we have an application installed in the Retriever. The Retriever then fires a query and can it get some information about the Client device(say the owners email address)? (Remember no special application is installed in the Client phone).
In this scenario the Client has an appropriate application installed that captures the NFC query, parses it, retrieves the relevant data from the Client and sends back an NFC message to the Retriever.
My background research says that it should be possible through the second way. I have two questions:
1.Is it possible through the first method. If yes then how?
2.Could you suggest me some good tutorial for the second method
Both scenarios are currently not possible with Android devices. Android apps on devices with NFC can push data via NFC to another device. There is no way to query and retrieve information (pull data) via NFC on Android.
With NFC tags, the Android device acts as a card reader/writer device. In that case the Android device can interrogate the tag and retrieve information from it.
From my experience both devices must have an app that is reade to receive a NFC event, the "caller" must have the application in foreground, when it gets close to other device, the "beam" appears and the NdefMessage is sent, on the receiver each application that has an intent filter for that MIME-TYPE can get launched and process the nfc event.
The reference as a starting point is this and the project sample from the API.
I have the following scenario
Phone A prepares an NDEF message and Phone B registers foreground
dispatch.
Phone A pushes the NDEF. Phone B receives this and processes it.
Phone A now registers for foreground dispatch and disables NDEF
push.Phone B replies with an NDEF push.
ALL this is to be done in one swipe. How can I do this?
Right now, I have to pull the devices away for the 2nd part to work. I
have seen the sample on p2p exchange, but in that case, both the
message contents are known in advance. Here, the reply depends on the
request.
Secondly, will there be a proper NFC API with the ability to create
LLCP sockets?
Cheers,
Earlence