That depends on what Nexus tablet you have:
Nexus 7 (first generation/2012 version): This device uses NXP's PN544 NFC controller. It seems that it's currently not possible to perform host-based card emulation with Android 4.4+ on these devices (see this question and my answer here).
Nexus 7 (second generation/2013 version) and Nexus 10: These devices use Broadcom's NFC controller. Therefore, you can use Android 4.4's HCE API to emulate a contactless smartcard.
With Android's HCE API you will emulate an ISO 14443-4 smartcard and you can only communicate using the application selection and APDU format defined in ISO 7816-4. You would first create and register a HCE service (see the API guide). Then you can process incoming APDUs using the service's processCommandApdu()
method (see this answer).
If your reader-side application currently only processes MIFARE Classic and Ultralight, you would have to extend it to also communicate with ISO 14443-4/APDU-based smartcards. (Emulation of non-APDU based cards like MIFARE Classic and Ultralight is not possible on top of ANdroid's HCE API.) The PN532 will typically handle the bigger part of this for you, so once you discover such a smartcard (e.g. with InListPassiveTarget
) it should automatically handle the ISO 14443-4 transport protocol and you can directly send APDU commands using the InDataExchange
command.
If you want to exchange NDEF messages over HCE, once you have APDU-based communication up and running, you could implement the NFC Forum's Type 4 Tag Operation specification (get it from the NFC Forum's website) within the Android HCE service to emulate a Type 4 NDEF tag.