Język

NdefFormatable.FormatReadOnlyAsync(NdefMessage) Method

Definition

Formats the tag for NDEF, optionally writes a message, and makes the tag read-only on a thread-pool thread.

public System.Threading.Tasks.Task FormatReadOnlyAsync(Android.Nfc.NdefMessage? firstMessage);
member this.FormatReadOnlyAsync : Android.Nfc.NdefMessage -> System.Threading.Tasks.Task

Parameters

firstMessage
NdefMessage

The NDEF message to write after formatting, or null to skip the message write before making the tag read-only.

Returns

A task that represents the call to FormatReadOnly(NdefMessage).

Remarks

This managed wrapper uses Task.Run to call FormatReadOnly(NdefMessage). Connect first and await the task before starting another operation. Making the tag read-only is irreversible. Formatting, writing, and locking are separate steps; a later failure does not undo an earlier step.

If the NFC service dies during the call, the pinned Android implementation logs the RemoteException and returns without throwing it. Task completion alone does not confirm that formatting, writing, or locking completed in this case.

The method has no cancellation-token parameter. Calling Close() from another thread cancels blocked I/O with IOException. Exceptions from the synchronous call are reported through the task. The NFC permission is required.

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.

Applies to