AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones NFC
  • Operating mode
  • Required permissions
  • Aplicación en segundo plano: Caso concreto de Android 10
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Starts writing data to an NFC tag.
Note: NFC functions cannot be used in the simulator or emulator.
Ejemplo
// Write URL to NFC tag (blocking mode)
tag is nfcTag
url is nfcData
url.Type = nfcURI
url.Content = "http://www.pcsoft.com"
Add(tag.Data, url)
NFCWriteTag(tag)
IF ErrorOccurred THEN
	Error("Unable to write NFC tag.", ErrorInfo())
END
// Write URL to NFC tag (non-blocking mode)
tag is nfcTag
url is nfcData
url.Type = nfcURI
url.Content = "http://www.pcsoft.com"
Add(tag.Data, url)
IF NOT NFCWriteTag(tag, WriteNFCTag) THEN
	Error("Unable to write NFC tag.", ErrorInfo())
END
INTERNAL PROCEDURE WriteNFCTag(nNFCResult is int)
	IF nNFCResult <> nfcOK THEN
		Trace("A problem occurred")
	END
END
Sintaxis

Writing a tag in blocking mode Ocultar los detalles

<Result> = NFCWriteTag(<Tag>)
<Result>: Integer
  • 1 if the writing was successful,
  • otherwise, one of the following constants:
    nfcErrDetectionThe NFC tag has exited from the detection control during the write process.
    nfcErrDisabledNFC is not enabled on the device.
    nfcErrEmulatorFunction called from the emulator.
    nfcErrFormatThe format of the data to write is invalid.
    nfcErrMaxSizeThe size of the data to write exceeds the maximum size of data that can be stored on the NFC tag.
    nfcErrNDEFThe NFC tag cannot be formatted to the NDEF format (NFC Data Exchange Format).
    nfcErrProtectionThe NFC tag cannot be protected in write mode (mode not supported by the tag).
    nfcErrReadOnlyThe NFC tag is protected in write mode.
    nfcErrUnknownUnknown error.

    If an error occurs, the ErrorOccurred variable is set to True. To get more details on the error, use ErrorInfo.
<Tag>: nfcTag variable
Name of the nfcTag variable describing the data to write.

Writing a tag in non-blocking mode Ocultar los detalles

<Result> = NFCWriteTag(<Tag> , <WLanguage procedure>)
<Result>: Boolean
  • True if the writing was started,
  • False otherwise.
<Tag>: nfcTag variable
Name of the nfcTag variable describing the data to write.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when writing data to the tag. This procedure is used to determine whether or not the data could be written to the tag. This procedure has the following format:
PROCEDURE <Procedure name>(<Result>)
where <Result> is the result of the writing operation:
  • 1 if data was successfully written to the tag,
  • otherwise, one of the following constants:
    nfcErrCancellationThe action was canceled by the user.
    nfcErrDetectionThe NFC tag has exited from the detection control during the write process.
    nfcErrDisabledNFC is not enabled on the device.
    nfcErrEmulatorFunction called from the emulator.
    nfcErrFormatThe format of the data to write is invalid.
    nfcErrMaxSizeThe size of the data to write exceeds the maximum size of data that can be stored on the NFC tag.
    nfcErrNDEFThe NFC tag cannot be formatted to the NDEF format (NFC Data Exchange Format).
    nfcErrProtectionThe NFC tag cannot be protected in write mode (mode not supported by the tag).
    nfcErrReadOnlyThe NFC tag is protected in write mode.
    nfcErrUnavailableThe NFC sensor does not exist or is not available.
    nfcErrUnknownUnknown error.
    nfcOKThe operation was completed.
Observaciones

Operating mode

The call to NFCWriteTag automatically opens a window to prompt users to hold their devices closer to the NFC tag to which they want to write.
This window will be automatically closed:
  • at the end of the write operation,
  • if the user cancels the operation by pressing the Back key of the device.
Note: To personalize the message displayed in this window, use the NextTitle function before calling the NFCWriteTagfunction. .
A vibration is triggered when the device detects the NFC tag. The device must be located near the NFC tag during the entire display of the capture window otherwise the write process will be interrupted.

Required permissions

This function changes the permissions required by the application.
Required permissions:
  • NFC: Enables applications to perform input/output operations using NFC technology.
  • VIBRATE: Accesses the vibrate function.
Android

Aplicación en segundo plano: Caso concreto de Android 10

A partir de Android 10, no se puede abrir una ventana si la aplicación está en segundo plano.
La función NFCWriteTag puede abrir una ventana. Si se utiliza esta función cuando la aplicación está en segundo plano, se producirá un error fatal.
Consejos:
  • Para saber si la aplicación está en segundo plano, utilice la función InBackgroundMode.
  • Si una aplicación necesita interactuar con el usuario cuando está en segundo plano, se puede mostrar una notificación (con el tipo Notification). La aplicación volverá al primer plano cuando se haga clic en la notificación, si la propiedad ActivateApplication se establece en True. También es posible abrir una ventana desde el procedimiento pasado a la propiedad ActionClick.
Para obtener más información, consulte Android 10: Comportamiento de las aplicaciones en segundo plano.
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300android.aar
Versión mínima requerida
  • Versión 18
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local