如何从 Activity 初始化我的 HostApduService?

How Can I Initialize My HostApduService from an Activity?

我需要使用 ApduResponse 对象初始化我的 HostApduServiceprocessCommandApdu 中的响应将使用此 ApduResponse 对象创建。我想在收到网络响应后初始化我的 HostApduService 以创建我的 ApduResponse 对象。我怎样才能做到这一点?

如文档中所述,当 Reader 与特定 AID 连接到您的设备 (HCE) 时,HCE 服务将启动。 https://developer.android.com/guide/topics/connectivity/nfc/hce.html#HceServices

One of the key advantages of a service is that it can run in the background without any user interface. This is a natural fit for many HCE applications like loyalty or transit cards, with which the user shouldn't need to launch the app to use it. Instead, tapping the device against the NFC reader starts the correct service (if not already running) and executes the transaction in the background. Of course, you are free to launch additional UI (such as user notifications) from your service if that makes sense.

要向您的服务发送特定的 ApduResponse,您需要在您的应用程序和 HCE 服务之间进行通信。请阅读:Passing information to a HostApduService from another Context