Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Desarrollo en Delphi para Android (https://www.clubdelphi.com/foros/forumdisplay.php?f=57)
-   -   Error al declarar variable tipo JObject, JLocation (https://www.clubdelphi.com/foros/showthread.php?t=92540)

jo3litro 22-11-2017 22:34:30

Error al declarar variable tipo JObject, JLocation
 
Buenas, estoy intendando declarar 2 variables del tipo:

JObjetc y
JLocation,

Que USES debo utilizar ?.

La aplicación es para compilar en Android.

Saludos y gracias.

Código Delphi [-]
procedure TLocationForm.botonClick(Sender: TObject);
var
    LocationManagerService: JObject;
    location : JLocation;
    begin
    
    end;
end;

Neftali [Germán.Estévez] 23-11-2017 10:15:36

¿Estaría bien saber qué quieres hacer?
Para el tema de Mapas en Android no necesitas ese tipo.

Visualizando y utilizando Mapas (Componente TMapView)

jo3litro 23-11-2017 12:41:53

Hola Neftali,

Lo que necesito es tomar datos de hora y fecha de la localizacion. Esta informacion debe tomarse del GPS y no del telefono.

Consegui un codigo donde aparentemente hace eso usando variables del tipo JObjetc y JLocation.

Código Delphi [-]
   
procedure TForm1.Button1Click(Sender: TObject);
    var
      LocationManagerService: JObject;
      location : JLocation;
    begin
      if not Assigned(FLocationManager) then
      begin
        LocationManagerService := SharedActivityContext.getSystemService(TJContext.JavaClass.LOCATION_SERVICE);
        FLocationManager := TJLocationManager.Wrap((LocationManagerService as ILocalObject).GetObjectID);
        if not Assigned(locationListener) then
          locationListener := TLocationListener.Create(self);
        FLocationManager.requestLocationUpdates(TJLocationManager.JavaClass.GPS_PROVIDER, 10000, 10, locationListener,
            TJLooper.JavaClass.getMainLooper);
      end;                      

      location := FLocationManager.getLastKnownLocation(TJLocationManager.JavaClass.GPS_PROVIDER);
  Memo1.Lines.Add(location.getTime.ToString);
    end;


Código Delphi [-]
Androidapi.JNI.JavaTypes, Androidapi.JNI.Location, System.Sensors,
  System.Sensors.Components,  Androidapi.Helpers,
  Androidapi.JNI.GraphicsContentViewText, Androidapi.JNIBridge,
  System.Android.Sensors;

Creo que estas son las unidades a declarar. Intentare con ellas y luego comento como me fue.

Neftali [Germán.Estévez] 23-11-2017 16:18:42

Código Delphi [-]
uses
  Androidapi.JNI.JavaTypes,
  Androidapi.JNIBridge,
  Androidapi.Helpers,
  Androidapi.JNI.GraphicsContentViewText,
  FMX.Helpers.Android,
  Androidapi.JNI.Os,
  Androidapi.JNI.App,
  Androidapi.JNI.Location;


La franja horaria es GMT +2. Ahora son las 22:59:55.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi