I know how to read and write ndef messages from a Mifare DESFire tag, but i'm having difficulty as to understand how to use the command set supported by DESFire when it comes to communicating from Android.
I know it has something to do with transceive(byte[])
function which help in communicating through raw bytes. How do i use it?
How do i lock the message with custom key?
IsoDep.transceive()
is indeed the proper method. You can send ISO7816-4 APDUs (like the ones from the NFC Forum Type 4 Tag specification) to the tag or use the DESfire-specific command set to communicate with the tag (see http://www.nxp.com/documents/short_data_sheet/MF3ICDX21_41_81_SDS.pdf for a high-level overview).
Locking a message with a custom key requires the use of the DESFire-specific commands. Details for that are described in the datasheet, which is available upon request from NXP; see http://www.nxp.com/products/identification_and_security/smart_card_ics/mifare_smart_card_ics/mifare_desfire/MF3ICD2101DUD.html