- Special cases
- Operating mode in iPhone/iPad
- Required permissions
- Required application feature
- Browsers allowing the geolocation
In french: GPSEtat
Retrieves the activation status of the geolocation provider or asks to be notified when the status changes.
Retrieves the activation status of the geolocation provider.
// Checks the status of the GPS provider
IF GPSStatus() = gpsDisabled THEN
Info("Geolocation is not enabled.")
Retrieving the activation status of the provider Hide the details
<Result> = GPSStatus()
<Result>: Integer constant
Activation status of the location provider. The following values can be returned:
Asking to be notified when the activation status changes Hide the details
<WLanguage procedure>: Procedure name
WLanguage procedure ("callback" procedure) called for each notification.
This procedure has the following format:
PROCEDURE <Procedure name>(<Status>)
<Status> is an integer constant corresponding to the new status of the provider.
It can take the following values:
|gpsAvailable||The provider is available.|
|gpsDisabled||The provider was disabled by the user.|
|gpsEnabled||The provider was enabled by the user.|
|gpsOffService||The provider is off service.|
|gpsUnavailable||The provider is temporarily unavailable.|
Operating mode in iPhone/iPad
When a GPS function is first run, the system requests geolocation permission from the user. If the user refuses, all the GPS functions used in the rest of the application will fail (fatal error).
To re-allow the use of GPS for this application, the system configuration of the application must be modified.
The call to this function modifies the permissions required by the application.
Required permission: ACCESS_FINE_LOCATION.
Android 11 specific case:
This function requires the ACCESS_BACKGROUND_LOCATION permission to access the device's location.
This permission allows using the function when the application is in the background.
If the application needs to use background location:
A window allows users to:
- Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
- Explicitly request background location permission with PermissionRequest. For example:
INTERNAL PROCEDURE Callback(p is Permission)
IF p.Granted THEN
// Functions that require background location access can be used
- allow access to the device location while the application is in the background,
- allow access to the location only while the application is in use,
- deny access to the location. The user can also change these permissions at any time in the Android settings.
- Follow Google's guidelines for applications that require background location access. For more details, see https://support.google.com/googleplay/android-developer/answer/9799150. If these conditions are not met (especially user information requirements), applications may not be accepted for publication on Google Play.
- The background location permission should only be requested if the location permission has been granted. Otherwise, PermissionRequest will fail.
- If the option chosen by the user for the background location access request is more restrictive than the option chosen for the location access request, the application will be automatically restarted.
- On devices running Android 10 or earlier, if location permission has been granted to the application, the background location permission will be granted without displaying a window.
Required application feature
When this function is used, an application feature is declared in the application generation wizard.
Required feature: Geolocation
This feature allows the applications to access the geolocation features found on the device or on the computer.
Browsers allowing the geolocation
: Geolocation is only available on certain modern browsers:
- FireFox from version 3.5,
- Chrome from version 5.0.342.1,
- Opera from version 10.6,
- Safari from version 5.0.
During the call to a geolocation function, the browser requests a location authorization.
Cross-platform examples (WINDEV Mobile): WM Geolocation
[ + ]
This example explains how to perform proximity searches with geolocation :
- search around me
- search in a city, at a given address, or close to a specific address.
The results are displayed in a looper and in a map with markers.
Android (WINDEV Mobile): Android GPS
[ + ]
This example presents the use of the GPS functions of WLanguage in an Android application.
It is used to retrieve at regular interval:
- The latitude
- The longitude
- The altitude
- The speed
- The direction
This page is also available for…