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 / Funciones estándar / Funciones de geolocalización
  • Casos especiales
  • Modo de funcionamiento en iPhone/iPad
  • Required permissions
  • Navegadores que permiten la geolocalización
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
Recupera el estado de activación del proveedor de geolocalización o pide ser notificado cuando cambia el estado.
WEBDEV - Código Navegador Recupera el estado de activación del proveedor de geolocalización.
Ejemplo
// Checks the status of the GPS provider
IF GPSStatus() = gpsDisabled THEN
Info("Geolocation is not enabled.")
END
AndroidWidget Android iPhone/iPadIOS WidgetMac Catalyst
// Branches a notification procedure if the status of the GPS is modified
GPSStatus(ProcGPSStatus)
// Procedure called whenever the status of the GPS is modified
PROCEDURE ProcGPSStatus(GPS_Status is int)
 
IF GPS_Status = gpsUnavailable THEN
Info("Geolocation not available.")
END
Sintaxis

Recuperación del estado de activación del proveedor Ocultar los detalles

<Result> = GPSStatus()
<Result>: Constante de tipo Integer
Estado de activación del proveedor de servicios de localización. Se pueden devolver los siguientes valores:
gpsDisabledEl proveedor está desactivado.
gpsEnabledEl proveedor está activado.
gpsErrorError al recuperar el estado de activación del proveedor. Para obtener más información sobre el error, utilice la función ErrorInfo.
WINDEVWEBDEV - Código Navegador Esta constante no está disponible.
WINDEVAndroidWidget Android iPhone/iPadIOS WidgetMac Catalyst

Pedir que se le notifique cuando cambie el estado de activación Ocultar los detalles

GPSStatus(<WLanguage procedure>)
<WLanguage procedure>: Nombre del procedimiento
Procedimiento WLanguage (procedimiento "callback") llamado para cada notificación.
Este procedimiento tiene el siguiente formato:
PROCEDURE <Procedure name>(<Status>)
<Status> es una constante entera que corresponde al nuevo estado del proveedor.
Puede tomar los siguientes valores:
gpsDisabledEl proveedor ha sido desactivado por el usuario.
gpsDisponibleEl proveedor está disponible.
gpsEnabledEl proveedor fue habilitado por el usuario.
gpsNo disponibleEl proveedor no está disponible temporalmente.
gpsOffServiceEl proveedor está fuera de servicio.
Observaciones

Casos especiales

  • AndroidWidget Android iPhone/iPadIOS WidgetMac Catalyst Se recomienda restablecer los parámetros del proveedor de localización con GPSInitParameter antes de recuperar el estado de este proveedor.
  • AndroidWidget Android iPhone/iPadIOS WidgetMac Catalyst Para dejar de recibir notificaciones cuando cambia el estado, utilice la función GPSStatus con una cadena vacía ("") como parámetro o utilice GPSEnd.
iPhone/iPadIOS WidgetMac Catalyst

Modo de funcionamiento en iPhone/iPad

Cuando se ejecuta por primera vez una función GPS, el sistema solicita permiso de geolocalización al usuario. Si el usuario se niega, todas las funciones GPS utilizadas en el resto de la aplicación fallarán (error fatal).
Para volver a permitir el uso del GPS en esta aplicación, es necesario modificar la configuración del sistema de la aplicación.
AndroidWidget Android

Required permissions

This function changes the permissions required by the application.
Permission required: 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:
  • Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
  • Explicitly request background location permission with PermissionRequest. For example:
    PermissionRequest(permBackgroundLocation, Callback)
    INTERNAL PROCEDURE Callback(p is Permission)
    	IF p.Granted THEN
    		// Functions that require background location access can be used
    	END
    END
A window allows users to:
  • 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.

Remarks:
  • 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.
WEBDEV - Código Navegador

Navegadores que permiten la geolocalización

During the call to a geolocation function, the browser requests a location authorization.
Componente: wd300java.dll
Versión mínima requerida
  • Versión 15
Esta página también está disponible para…
Comentarios
Exemplo
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/3701-trabalhando-com-gps/read.awp
Boller
13 03 2021
EXAMPLE: GPS status and on / off GPS via Java
FONTE:

http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/9-windev-mobile-verifica-gps-ligado-posicao/read.awp

---x---

Example 01:
#####################################################

Procedure GPS_VerificaStatus()

Retorno is string = ""

GloLatitude , GloLongitude is real = 0

GPSInitParameter(gpsSatellite,gpsPrecisionHigh)

// Recuperação da posição
Retorno is geoPosition = GPSGetPosition() // 2000 = Intervalo máxo,p de 20 segundos

GloLatitude = NumToString(Retorno..Latitude,"+-10.6f")
GloLongitude = NumToString(Retorno..Longitude,"+-10.6f")

Retorno = GloLatitude +"; "+ GloLongitude

IF GloLatitude = 0 AND GloLongitude = 0 OR GloLatitude = null AND GloLongitude = null
ToastDisplay("GPS Desligado!!!")
END

RESULT(Retorno )

---x---



Example 02:
#####################################################

//Java GPS_On

import android.app.Activity;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

PUBLIC static void GPS_On()
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", True);
getActiviteEnCours().sendBroadcast(intent);
}

---x---

//Java GPS_Off

import android.app.Activity;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

PUBLIC static void GPS_Off()
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", False);
getActiviteEnCours().sendBroadcast(intent);
}


---x---

OBS.:
You must enable these options in the Android Manifest XML Windev Mobile

A) Android.Permission.WRITE_SECURE_SETTINGS

B) Android.Permission.WRITE_SETTINGS

---x---



Example 03
#####################################################
Another way to test whether this off GPS:

// GLOBAL
GloGpsAtivado is boolean = False

//Open Window
Procedure GPS_Inicializar()

GPSInitParameter(gpsSatellite,gpsPrecisionHigh +gpsSpeed)

IF GPSStatus() <> gpsEnabled THEN

Popup("Para melhorar a precisão da sua localização, ative o seu GPS","L")

gloStatusGps = False

ELSE
ChangeGPSStatus(GPSStatus())
END

GPSStatus(ChangeGPSStatus)

---x---

//Procedure Global

Procedure ChangeGPSStatus(nStatus)
IF gnCurrentStatus = nStatus THEN
RETURN
END

gnCurrentStatus = nStatus

IF nStatus = gpsEnabled OR nStatus = gpsAvailable THEN

GPSFollowMovement(GetPosition,300)

END

SWITCH nStatus
CASE gpsEnabled
GloGpsAtivado = True // <------------- Ligado
CASE gpsDisabled
GloGpsAtivado = False // <------------- Desligado
gloStatusGps = False
CASE gpsOffService
CASE gpsUnavailable
CASE gpsAvailable
END

adrianoboller
14 02 2015

Última modificación: 30/09/2024

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