问题
I have my own Android app (App A) which reads and writes NFC tags and ISO-14443 Type A tags. It works well on many Android devices.
I want to give the role of ISO-14443 tag to my Nexus5, so I implemented my own HCE (Host Card Emulation) application (App B) on my Nexus5. When I touch the Nexus5 on an external NFC reader (which uses ISO 14443), it works perfectly.
However, when I touch the Nexus5 (App B) on a Nexus7 (running App A), p2p (Android beam) data exchanging sequences start.
Even after I turn off Android beam functions on both devices, nothing changes. The Nexus7 doesn't display the 'Touched to Beam' screen, but the p2p detect sound plays.
LogCat shows that Nexus7 tries to establish an LLCP connection.
I want that Nexus7 to focus on detecting the ISO-14443 HCE of Nexus5, not Android beam.
How do I change the NFC detection priority to give preference to ISO-14443 over Android beam?
回答1:
The solution is only available on Android 4.4 Kitkat (which is available for the Nexus 7). You need to enable so-called "reader mode", which is designed to handle this particular situation, using enableReaderMode().
In this mode the NFC controller will only act as an NFC tag reader/writer, thus disabling any peer-to-peer (Android Beam) and card-emulation modes of the NFC adapter on this device. [...] For interacting with tags that are emulated on another Android device using Android's host-based card-emulation, the recommended flags are
FLAG_READER_NFC_A
andFLAG_READER_SKIP_NDEF_CHECK
.
来源:https://stackoverflow.com/questions/20821701/android-how-to-change-nfc-protocol-priority