Skip to content

Most visited

Recently visited

added in API level 14


public static interface NfcAdapter.CreateNdefMessageCallback


A callback to be invoked when another NFC device capable of NDEF push (Android Beam) is within range.

Implement this interface and pass it to setNdefPushMessageCallback() in order to create an NdefMessage at the moment that another device is within range for NFC. Using this callback allows you to create a message with data that might vary based on the content currently visible to the user. Alternatively, you can call setNdefPushMessage() if the NdefMessage always contains the same data.


Public methods

abstract NdefMessage createNdefMessage(NfcEvent event)

Called to provide a NdefMessage to push.

Public methods


added in API level 14
NdefMessage createNdefMessage (NfcEvent event)

Called to provide a NdefMessage to push.

This callback is usually made on a binder thread (not the UI thread).

Called when this device is in range of another device that might support NDEF push. It allows the application to create the NDEF message only when it is required.

NDEF push cannot occur until this method returns, so do not block for too long.

The Android operating system will usually show a system UI on top of your activity during this time, so do not try to request input from the user to complete the callback, or provide custom NDEF push UI. The user probably will not see it.

event NfcEvent: NfcEvent with the nfcAdapter field set
NdefMessage NDEF message to push, or null to not provide a message
This site uses cookies to store your preferences for site-specific language and display options.


This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.