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
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Starts writing data to an NFC tag.
Note: NFC functions cannot be used in the simulator or emulator.
Example
// Ecrit une url dans un tag NFC (mode bloquant)
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("Echec de l'écriture sur le tag NFC.", ErrorInfo())
END
// Ecrit une url dans un tag NFC (mode non bloquant)
tag is nfcTag
url is nfcData
url.Type = nfcURI
url.Content = "http://www.pcsoft.com"
Add(tag.Data, url)
IF NOT NFCWriteTag(tag, EcritureTagNFC) THEN
	Error("Echec lors de l'écriture NFC.", ErrorInfo())
END
INTERNAL PROCEDURE EcritureTagNFC(nRésultatNFC is int)
	IF nRésultatNFC <> nfcOK THEN
		Trace("Un problème est survenu")
	END
END
Syntax

Writing a tag in blocking mode Hide the details

<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 Hide the details

<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.
Remarks

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

Application in the background: Specific case from Android 10

Starting with Android 10, it is no longer possible to open a window when the application is in the background.
NFCWriteTag can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Related Examples:
WM System Cross-platform examples (WINDEV Mobile): WM System
[ + ] This application is an example of some of the features of WINDEV Mobile available for Android/iOS.
The following system functions are used:
- NFC
- Multimedia control
- Brightness
- Volume
- Wi-Fi
- Bluetooth
- Toast
- Compass
- Accelerometer
- Camera control
- LED
- Vibration
- Notifications
- Drawing functions
- Internet
Business / UI classification: Business Logic
Component: 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