Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test NFC api?

Tags:

android

nfc

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

like image 485
Thomas Clayson Avatar asked Feb 16 '12 16:02

Thomas Clayson


Video Answer


2 Answers

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.

like image 188
NFC guy Avatar answered Sep 22 '22 21:09

NFC guy


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

like image 24
tanuj Avatar answered Sep 25 '22 21:09

tanuj