I wanna emulate a host card with the HCE feature from Android. For that I extend the service class HostApduService and overwrite following method:
public byte[] processCommandApdu(byte[] commandApdu, Bundle extras) {
if (Arrays.equals(SELECT_APDU, commandApdu)) {
NdefMessage message = new NdefMessage(new NdefRecord [] {NdefRecord.createTextRecord("en", "test"});
return message.toByteArray();
} else {
return UNKNOWN_CMD_SW;
}
}
With a second device its possible to receive data from the HCE Service. The problem is that I always receive "Type A" Tag, but I need a NDEF Message.
Can anybody help me?
For anyone who stuck on this issue, I have read NFCForum-TS-Type-4-Tag which proposed by @Michael Roland. The whole idea is correct. All you need is to simulate the process SEND and RECEIVED commands to convert the byte array to a NDEF message. I created two repositories, one conclude the whole package about converting string to a NDEF message and the other one is a iOS Reader NDEF TAG to verify whether Android HCE is correct or not.
So Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With