Stay organized with collections
Save and categorize content based on your preferences.
NfcAdapter.CreateNdefMessageCallback
public
static
interface
NfcAdapter.CreateNdefMessageCallback
android.nfc.NfcAdapter.CreateNdefMessageCallback
|
This interface was deprecated
in API level 29.
this feature is removed. File sharing can work using other technology like
Bluetooth.
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 NfcAdapter#setNdefPushMessageCallback 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 setNdefPushMessage()
if the NdefMessage
always contains the
same data.
Summary
Public methods
createNdefMessage
public abstract 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.
Returns |
NdefMessage |
NDEF message to push, or null to not provide a message |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# NfcAdapter.CreateNdefMessageCallback\n\nAdded in [API level 14](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nDeprecated in [API level\n29](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nNfcAdapter.CreateNdefMessageCallback\n====================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/nfc/NfcAdapter.CreateNdefMessageCallback \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nNfcAdapter.CreateNdefMessageCallback\n`\n\n\n`\n\n\n`\n\n|--------------------------------------------------|\n| android.nfc.NfcAdapter.CreateNdefMessageCallback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\n**This interface was deprecated\nin API level 29.** \n\nthis feature is removed. File sharing can work using other technology like\nBluetooth.\n\nA callback to be invoked when another NFC device capable of NDEF push (Android Beam)\nis within range.\n\nImplement this interface and pass it to `NfcAdapter#setNdefPushMessageCallback setNdefPushMessageCallback()` in order to create an\n[NdefMessage](/reference/android/nfc/NdefMessage) at the moment that another device is within range for NFC. Using this\ncallback allows you to create a message with data that might vary based on the\ncontent currently visible to the user. Alternatively, you can call `#setNdefPushMessage setNdefPushMessage()` if the [NdefMessage](/reference/android/nfc/NdefMessage) always contains the\nsame data.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[NdefMessage](/reference/android/nfc/NdefMessage) | ` `[createNdefMessage](/reference/android/nfc/NfcAdapter.CreateNdefMessageCallback#createNdefMessage(android.nfc.NfcEvent))`(`[NfcEvent](/reference/android/nfc/NfcEvent)` event) ` Called to provide a [NdefMessage](/reference/android/nfc/NdefMessage) to push. |\n\nPublic methods\n--------------\n\n### createNdefMessage\n\nAdded in [API level 14](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract NdefMessage createNdefMessage (NfcEvent event)\n```\n\nCalled to provide a [NdefMessage](/reference/android/nfc/NdefMessage) to push.\n\nThis callback is usually made on a binder thread (not the UI thread).\n\nCalled when this device is in range of another device\nthat might support NDEF push. It allows the application to\ncreate the NDEF message only when it is required.\n\nNDEF push cannot occur until this method returns, so do not\nblock for too long.\n\nThe Android operating system will usually show a system UI\non top of your activity during this time, so do not try to request\ninput from the user to complete the callback, or provide custom NDEF\npush UI. The user probably will not see it.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `event` | `NfcEvent`: [NfcEvent](/reference/android/nfc/NfcEvent) with the [NfcEvent.nfcAdapter](/reference/android/nfc/NfcEvent#nfcAdapter) field set \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------------------|---------------------------------------------------------------|\n| [NdefMessage](/reference/android/nfc/NdefMessage) | NDEF message to push, or null to not provide a message \u003cbr /\u003e |"]]