问题
I am trying to develop an Android application for a hospital. In this system there is a need to get the patient information stored in the database in the android phone into the desktop computer using NFC technology. Is there anyway where I could use a NFC USB Reading device (ACR122U NFC Smart Card Reader RFID Writer 5 Mifare USB) to transfer the data from the mobile phone to my desktop computer?
The real scenario for this would be, in a hospital when a person wants to take some test results he will reach to the counter and place the mobile device on the NFC reader device installed at the counter when this is done all the details about the patient should be transferred to the desktop machine at the counter.
I don't want to transfer a lot of information if there is any way in which I could transfer the patient id stored in the mobile database into the desktop using NFC that would be enough.
回答1:
Depending on what NFC devices you want to use in combination with the ACR122U NFC reader you multiple options:
If you only need to exchange a single message (data packet) in a single direction, you could use peer-to-peer mode. However, the peer-to-peer protocol stack is relatively complex (in comparison to the other alternatives). Moreover, Android's built in Beam functionality will request user confirmation (Beam UI) for every message transfer.
If you only need to support Android devices with Android 4.4 or later (and even then not all Android NFC devices are supported, see this), you could use the ACR122U in reader/writer mode. In reader/writer mode, the ACR122U can communicate with contactless smartcards. See the reader's manual on how to access such ISO/IEC 14443-4 contactless smartcards. On the Android side, you would use the host-based card emulation (HCE) mode. See the Android documentation on how that works on Android 4.4 and later.
In my opinion the best option would be to use the ACR122U in card emulation mode. In card emulation mode the ACR122U can be used to emulate a tag/contactless smartcard that can be detected by an Android device just like any other NFC tag/contactless smartcard. You can find examples, for instance, with libnfc. Also see this answer on how to bring the ACR122U into card emulation mode. This option can be used across all Android versions (and on BlackBerry and with some additional effort to some extent even on Windows Phone). With this scenario, the phone would take the reader (interrogator) part in the communication and the ACR122U (and the connected PC) would be the card (controlled component). Using techniques like inverse reader mode you could reverse that relationship.
回答2:
You could use the host based card emulation for exchanging the data: http://developer.android.com/guide/topics/connectivity/nfc/hce.html
Or alternatively the p2p communication:
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#p2p
来源:https://stackoverflow.com/questions/24096356/transfer-data-to-pc-from-android-device-via-nfc