Question

I have a Nexus S with NFC and the Android API and such.

I assume that NFC isn't simulated via the emulator (?).

And I only have the one NFC enabled phone.

Can I use RFID cards to test NFC apps I make? Or will I have to get another NFC enabled phone?

Thanks

Was it helpful?

Solution

NFC has two different modes: card reading/writing and phone peer-to-peer communication. Testing card reading/writing functionality in your NFC app generally requires real cards. In some cases, when the card contains a so-called NDEF-formatted message that is automatically read from the card by the Android OS and delivered to your app in an Intent, you could test or simulate this by generating the corresponding Intent yourself. In Android, peer-to-peer mode corresponds to Android Beam. Receiving an Android beam message in your app works the same as detecting an NDEF message from a card: Android delivers the NDEF message in an Intent to your app. For all means and purposes, the Intent is virtually the same as the one delivered from a card containing the same message. So receiving an Android Beam message can be simulated using a card (assuming the card's memory is large enough to store the message). For testing the sending of an Android Beam message, I cannot think of any other way than using a second phone.

OTHER TIPS

This may also be of some help to you.

FakeTagsActivity — A activity that launches tags as if they had been scanned. This is useful if you don't have access to NFC enabled device or tag.

http://developer.android.com/resources/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.html

There is also the Open NFC project, which allows you to run an Android emulator with the Open NFC stack. You can then use the NFC simulator to present any RFID card to the emulator.

I've been using it to test my Android NFC projects. However I must say that it's quite a hassle to get it up and running. I also found the emulator to be unstable and loose the connection with adb. Anyway you could give it a try: http://open-nfc.org

I recommend ordering some tags online to get familiar with the technology. You probably do not want to do longer session through NFC anyways, so embedding some NDEF messages in tags for a one-shot is a good starting point. I also got a lot out of this Android guide.

I have created an NFC Eclipse Plugin which might be interesting to you, it comes with a corresponding (free) Android application which does the actual NFC interfacing and should be good for entry-level NFC developers.

Edit: Plugin now also supports some card readers :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top