Kaleb Jacobsen
Kaleb Jacobsen

Reputation: 13

How to detect a NFC P2P event

Android allows you to prepare NFC push messages using either NfcAdapter.setPushMessage or NfcAdapter.setPushMessageCallback. My understanding is that after setting the push message or callback, the message will be sent on the next NFC event (such as tapping two phones together).

Is there a way to detect when that event has happened?

Upvotes: 1

Views: 203

Answers (1)

Michael Roland
Michael Roland

Reputation: 40851

Yes, NfcAdapter.setOnNdefPushCompleteCallback() allows you to register a callback for exactly that purpose: get a notification when the NDEF message was successfully transfered to the other device.

Btw. the CreateNdefMessageCallback (registered by NfcAdapter.setNdefPushMessageCallback()) is typically called as soon as a device capable of receiving the NDEF message is in range. So you can even approximate the start and the end of the NDEF push (Beam) transaction.

Upvotes: 1

Related Questions