简体   繁体   中英

Android hand over ByteArray to Host Card Emulation Service

how can i hand over from my activity a ByteArray to the Host Card Emulation (HCE) service?

I tryed it with an Intent.putExtra() like this:

    val cert: ByteArray
    val intent = Intent(this, MyHostApduService::class.java)
        intent.putExtra("byteArray", cert)
        startService(intent)

In the HCE service i can not access the intent anymore! Like this:

 val cert = intent.getByteArrayExtra("byteArray")

How can I hand over the byte array? Thanks in advance!

Inside the the HCE service there is a method which can be overreaden like this:

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    super.onStartCommand(intent, flags, startId)


    if (intent!!.hasExtra("<KEY>")) {
        var arr = intent.getByteArrayExtra("<KEY>")
    }


    return flags
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM