问题
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?
回答1:
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.
回答2:
First of all you must ensure you use Kitkat version of android to have HCE Support. Next, since HCE routs your Application ID to CPU and not to eSE or UICC Sim card, any app which depends on eSE or UICC sim card doesnt work with HCE. So you must be using HCE supported app to be identified by the reader. Next, the reader should send out Application ID such that any installed HCE app on your phone is able to respond to it.
来源:https://stackoverflow.com/questions/33132193/host-based-card-emulation-trigger-a-reader-app-when-hce-is-read-on-reader-devi