Język

NdefFormatable.FormatAsync(NdefMessage) Method

Definition

Formats the tag for NDEF and optionally writes an initial message on a thread-pool thread.

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

Parameters

firstMessage
NdefMessage

The NDEF message to write after formatting, or null to format without writing a message.

Returns

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

Remarks

This managed wrapper uses Task.Run to call Format(NdefMessage). Connect first and await the task before starting another operation. Formatting and writing 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 all steps 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