PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Use in locking mode (Syntax 1)
  • Use in non-locking mode (Syntax 2)
  • Required permissions
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.
Notes:
  • The NFC functions cannot be used in the simulator or in the emulator.
  • The NFC functions are available for the devices running Android version 2.3.3 or later (api level 10).
    A fatal error will occur if the function is used with an earlier system version.
    Reminder: To find out the version of Android system on which the application is run, use SysAndroidVersion.
Example
// Read a NFC tag in locking mode
tag is nfcTag
tag = NFCReadTag()
IF NOT ErrorOccurred THEN
Info(StringBuild("Reading a NFC tag of %1 type", tag..Type))
FOR EACH data OF tag..Data
SWITCH data..Type
CASE nfcText
Info(data..Content)
CASE nfcURI
IF StringStartsWith(data..Content, "http") THEN
BrowserRunApp(data..Content)
END
CASE nfcMedia
IF data..MIMEType ~= "image/png" THEN
fSaveBuffer(CompleteDir(SysDirStorageCard()) +  ...
"image.png", data..Content)
END
END
END
END
PROCEDURE ReadNFCTag(tag is nfcTag)
Info(StringBuild("A NFC tag of %1 type was detected.", tag..Type))
// Stop the detection
RESULT True
Syntax

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 find out the error details, use ErrorInfo.

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

<Result> = NFCReadTag(<Procedure Name>)
<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 find out the error details, use ErrorInfo.
<Procedure Name>: Character string (with or without quotes)
Name of the WLanguage procedure ("callback") called when a NFC tag was read. This procedure has the following format :
PROCEDURE <Procedure Name> (<Tag>)
where <Tag> is a nfcTag variable containing the information read in the NFC tag.
Notes:
  • 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

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.
    Note: 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.

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.
Related Examples:
Android System Android (WINDEV Mobile): Android System
[ + ] This application is a tutorial example presenting some of the new features of WINDEV Mobile for Android.
The following system functions are used:
- NFC
- Multimedia control
- Brightness
- Volume
- WIFI
- Bluetooth
- Toast
- Progress Bar control
- 9-image mode
- Compass
- Accelerometer
- Camera control
- LED
- Vibrations
- Notifications
- Drawing functions
- Internet
Components
Android wd230android.jar
Minimum required version
  • Version 18
Comments
Click [Add] to post a comment