1
votes

I wanted to use my Android mobile as a reader to communicate to my android HCE(Host card EMulation) App. In internet I found the sample client application code for ACS Reader(PC Reader). Instead of that I would like to use my Android phone as a NFC Reader. I found some sample for Mifare cards for Android, not for HCE communication

Please share If in case any sample code URL /API to help me for the same. Thank You

3

3 Answers

5
votes

Not really sure what you are asking for, but here are two samples. One if for an Android NFC reader app and one is for an Android HCE app.

https://github.com/googlesamples/android-CardReader

https://github.com/googlesamples/android-CardEmulation

Please clarify your question if I did not understand you correctly.

CardReader

This sample demonstrates how to implement a low-level NFC card reader, for reading cards that do not contain NDEF or Android Beam data. This sample is designed to read the virtual loyalty card implemented in the CardEmulation sample.

In particular, this sample demonstrates how to disable Android Beam, select which AIDs the reader is interested in, and establish communication with the card. See Host-based Card Emulation for more information on the HCE APIs.

CardEmulation

This sample demonstrates how to emulate an NFC card, using the Host Card Emulation feature added in Android 4.4. This sample makes the device appear as a loyalty card whenever the screen is on and the user taps their device on an appropriately configured NFC reader.

The CardReader sample can be used to read the loyalty card implemented in this sample.

2
votes

You can use an Android device (NFC+Kitkat onwards) in reader mode. Use NFCAdapter enableReaderMode function. This blog has complete sample.

Thanks

0
votes

If I understand correclty your issue, you want to use one android device as an NFC reader to communicate with an HCE application installed on another android device. Am I right? In this case, I do not think this is possible, because when you approach 2 NFC android devices, they will start to communicate in P2P. In order to activate the CE mode on your "reading" device, you would need to deactivate the P2P feature, which is not possible if your phone is not rooted.