NFC card emulation with closed reader application

无人久伴 提交于 2019-12-06 11:59:31

Unfortunately, that's not possible. Due to the way the Android NFC stack implements polling for other NFC devices (peer-to-peer mode and NFC tags) it is not possible to launch a reader application on one Android device through a host-based card emulation (HCE) application on another Android device.

The Android NFC stack, by default polls for both, NFC tags and NFC peer-to-peer devices. As a result, when two Android devices are held together, they will automatically communicate through NFC peer-to-peer mode and not through reader/writer mode + card emulation mode.

As a consequence, the "reader" device cannot detect the HostApduService running on the second device. Therefore, an Android device cannot emulate an NFC tag (that contains an NDEF message) that would trigger an application (that filters for an NDEF_DISCOVERED intent or even a TECH_DISCOVERED or TAG_DISCOVERED intent) on a second Android device.

The only way to communicate between one Android device (that is in reader/writer mode) and an HCE application (HostApduService) on a second Android device is by using the reader mode API). This disable peer-to-peer polling and consequently allows the reader Android device to discover the card emulation mode of the other device. However, in order to use this API your application must already have a foreground activity running on the reader device.

Note that disabling Android Beam (through the Settings app) won't disable peer-to-peer mode. So doing this won't change anything.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!