PC SOFT
DEPOT EN LIGNE
POUR WINDEVWEBDEV ET WINDEV MOBILE

Exemplo WINDEV Mobile com GPS e Intinerário
Publié par Boller
dans la catégorie Outils
Nouveautés



Description
Exemplo WINDEV Mobile com GPS e Intinerário

https://forum.PC SOFT.fr/fr-FR/PC SOFT.br.WINDEV/3701-trabalhando-com-gps/read.awp
Illustrations, copies d'écran
none
none
Avis des utilisateurs
(Pour noter la ressource, cliquez sur Ecrire un avis)
Boller
PROCEDURE GPS_BuscaEndereco()

//Site Here Maps = https://developer.here.com/projects/PROD-1a48d00b-5e35-4f20-b50e-72d5dd4f77de

//glo_GpsLatitude = -25.2548
//glo_GpsLongitude = -49.1615

ApiKeyHere is string = "I_FQBhS2Odl8ZHLbLu_cPQzEh2J692-0I27qMgxx8GM"
Url is string = "https://revgeocode.search.hereapi.com/v1/revgeocode?at="+glo_GpsLatitude+","+glo_GpsLongitude+"&apiKey="+ApiKeyHere
Res is string = ""

ok is boolean = HTTPRequest(Url)

JsonHere is JSON = HTTPGetResult()

IF ok=True THEN
Res = JsonHere.items[1].address.label
ELSE
Res = ""
END

RETURN Res
Boller
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