PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Use in locking mode (Syntax 1)
  • Use in non-locking mode (Syntax 2)
  • Other notes
  • Required permissions
  • AppID required
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Starts reading a NFC tag or enables the detection of NFC tags for the current window.
Versions 24 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 24
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Example
// Lecture d'un tag NFC en mode bloquant
tag is nfcTag
tag = NFCReadTag()
IF NOT ErrorOccurred THEN
Info(StringBuild("Lecture d'un tag NFC de type %1", tag.Type))
FOR EACH donnée OF tag.Data
SWITCH donnée.Type
CASE nfcText
Info(donnée.Contenu)
CASE nfcURI
IF StringStartsWith(donnée.Contenu, "http") THEN
BrowserRunApp(donnée.Contenu)
END
CASE nfcMedia
IF donnée.TypeMIME ~= "image/png" THEN
fSaveBuffer(CompleteDir(SysDirStorageCard()) + ...
"image.png", donnée.Contenu)
END
END
END
END
// Lecture d'un tag NFC en non bloquant
IF NOT NFCReadTag(LectureTagNFC) THEN
Error("Echec du lancement de la détection NFC.", ErrorInfo())
END
 
INTERNAL PROCÉDURE LectureTagNFC(tag is nfcTag)
Info(StringBuild("Tag NFC de type %1 détecté.", tag.Type))
// Arrêt de la détection
RETURN True
END
Syntax
Android

Reading a NFC tag in locking mode Hide the details

<Result> = NFCReadTag()
<Result>: nfcTag variable
nfcTag variable initialized with the information read in the NFC tag.
The ErrorOccurred variable is set to True if an error occurred. To get the details of the error, use ErrorInfo.

Reading a NFC tag in non-locking mode Hide the details

<Result> = NFCReadTag(<WLanguage procedure>)
<Result>: Boolean
  • True if the detection of NFC tags was triggered,
  • False otherwise. The ErrorOccurred variable is set to True if an error occurred. To get the details of the error, use ErrorInfo.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when a NFC tag was read. This procedure has the following format :
PROCEDURE <Nom de la procédure> (<Tag>)
where <Tag> is a nfcTag variable containing the information read in the NFC tag.
Remarks:
  • The parameters of this procedure are optional. There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled during each call.
  • If the procedure returns True, the detection of NFC tags will be automatically stopped after the reading.
  • If the procedure returns False or if it returns no value, the detection will remain active as long as the window in which the procedure was triggered is not closed.
Remarks
Android

Use in locking mode (Syntax 1)

The call to NFCReadTag automatically opens a window asking the user to move his device near another device compatible with NFC. This window will be automatically closed:
  • when the sending is over
  • if the user cancels the sending by pressing the Back key of the device.
    Remark: To customize the message displayed in this window, use NextTitle before the call to NFCReadTag.

Use in non-locking mode (Syntax 2)

The call to NFCReadTag starts detecting the NFC tags for the current window at the time of the call.
The detection will be active when this window is displayed in the foreground of the application.
When the window is closed, the detection is stopped and it will have to be restarted by a call to NFCReadTag.
A fatal error will occur if there is no current window during the call to NFCReadTag.

Other notes

  • The NFC functions cannot be used in the simulator or in the emulator.
  • Versions 24 and later
    iPhone/iPad The NFC functions are only available in read-only mode.
    New in version 24
    iPhone/iPad The NFC functions are only available in read-only mode.
    iPhone/iPad The NFC functions are only available in read-only mode.

Required permissions

The call to this function modifies the permissions required by the application.
Required permissions:
  • NFC: Allows the applications to perform input/output operations via the NFC technology.
  • VIBRATE: Used to access the sensor feature.
Versions 24 and later
iPhone/iPad

AppID required

Calling this function modifies the AppIDs of the application in the Apple developer account. It is necessary to activate the "NFC Tag Reading" App ID..
New in version 24
iPhone/iPad

AppID required

Calling this function modifies the AppIDs of the application in the Apple developer account. It is necessary to activate the "NFC Tag Reading" App ID..
iPhone/iPad

AppID required

Calling this function modifies the AppIDs of the application in the Apple developer account. It is necessary to activate the "NFC Tag Reading" App ID..
Versions 25 and later
Android

Application in the background: Specific case from Android 10

From Android 10, it is no longer possible to open a window when the application is in the background.
NFCReadTag 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.
New in version 25
Android

Application in the background: Specific case from Android 10

From Android 10, it is no longer possible to open a window when the application is in the background.
NFCReadTag 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.
Android

Application in the background: Specific case from Android 10

From Android 10, it is no longer possible to open a window when the application is in the background.
NFCReadTag 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: wd260android.jar
Minimum version required
  • Version 18
Comments
Click [Add] to post a comment