NfcAdapter.SetNdefPushMessage(NdefMessage, Activity, Activity[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets a static NDEF message to send using Android Beam.
[Android.Runtime.Register("setNdefPushMessage", "(Landroid/nfc/NdefMessage;Landroid/app/Activity;[Landroid/app/Activity;)V", "")]
public void SetNdefPushMessage(Android.Nfc.NdefMessage? message, Android.App.Activity? activity, params Android.App.Activity[]? activities);
[<Android.Runtime.Register("setNdefPushMessage", "(Landroid/nfc/NdefMessage;Landroid/app/Activity;[Landroid/app/Activity;)V", "")>]
member this.SetNdefPushMessage : Android.Nfc.NdefMessage * Android.App.Activity * Android.App.Activity[] -> unit
Parameters
- message
- NdefMessage
The static NDEF message to push over NFC, or null to clear the static message provider.
- activity
- Activity
The non-null activity for which the NDEF message will be pushed.
- activities
- Activity[]
A non-null array of additional non-null activities. Pass an empty array if there are no additional activities. Register one activity at a time from that activity's OnCreate method.
- Attributes
Exceptions
The device does not support NFC.
The specified activity has already been destroyed.
On Android versions where Android Beam is functional, activity, activities, or an element of activities is null.
Remarks
Android Beam was deprecated in API level 29. On devices that support Android Beam, it remains functional through API level 33. Starting in API level 34, Android Beam is removed and calls to this method have no effect.
The message is made available for NDEF push only while a specified activity is resumed. Call this method before Activity.OnDestroy, preferably from Activity.OnCreate. It does not perform I/O or blocking work and is safe to call from the main thread.
Only one NDEF message can be pushed by the resumed activity. If a message callback is also set with SetNdefPushMessageCallback, the callback takes priority. Passing null clears the static message provider; a registered callback continues to supply the NDEF message.
Use SetNdefPushMessageCallback when the message must be generated dynamically. Do not pass an activity that has already reached Activity.OnDestroy.
Requires the android.Manifest.permission#NFC permission.
Android Open Source Project source documentation for android.nfc.NfcAdapter.setNdefPushMessage.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.