androidnfchceandroid-beam

Host-based Card Emulation - Trigger a reader app when HCE is read on reader device


NFC tags can trigger an NFC reader app available on the phone, but HCE does not trigger any reader app. However, if I first open the reader app, then it works normally and, hence, can read the HCE emulated tag.

I need a solution where HCE can open or prompt to choose the reader app.

Is this possible with HCE? Why does Android not prompt to open an NFC reader app when detecting a HCE device?


Solution

  • No, a HCE app on one Android device cannot be used to trigger (launch) a reader app on another Android device. The reason for this is that Android devices also implement peer-to-peer mode. Thus, by default, two Android devices will automatically communicate in peer-to-peer mode and the reader side won't see the HCE emulated tag.

    Only if a reader app is started on the reader side that uses the reader-mode API to disable peer-to-peer mode, the two devices start communicating in reader/writer mode + card emulation mode. Thus, only then the HCE emulated tag becomes visible to the reader side.

    Note that disabling Beam from the settings menu won't change anything about this because peer-to-peer mode stays enabled even if Beam (currently the only application protocol used by Android devices on top of peer-to-peer mode) is disabled.