Official Content

This method is provided by the Maps external object. It triggers the GPS to start tracking the device's location. The updated location will be changed for every ChangesInterval and also if the device moves a certain distance.

Return value None
Parameters TrackingParameters SDT

TrackingParameters SDT members

  • ChangesInterval: Numeric (8.0)

Specifies the minimum time in seconds between change updates. 0 means ignore this parameter.

  • Distance: Numeric (8.0)

Specifies the minimum distance between change updates. 0 means any distance.

  • Action: Character (20)

Specifies the name of the action that the app will automatically call to process the latest updates of the Tracking methods. 

This action must be defined in the Main Object:

  • In case of a Main Panel object, the action should be defined as an event. 
  • In case of a Main Menu object, it should be defined as an Item or Notification (Notifications area). For more information, refer to the Samples section.

Important: The called action must be an event that does not contain any UI interaction.

  • ActionTimeInterval: Numeric (8.0)

Specifies the minimum time that must elapse before the action is executed again. The value entered in this parameter must be greater than ChangesInterval; otherwise, this parameter will be ignored. This time interval is restarted when the Action is executed, and is not affected when the geolocation changes.

  • Accuracy: Numeric (8.0)

Measurement in meters per second of the device's movement.

  • UseForegroundService: Boolean

Only for the Android Platform. You need to enable this option to use this method on Android Devices with an operating system greater than or equal to Android 8.

Consideration

As the StartTracking method is also supported by the Geolocation external object, it also accepts scalar parameters as follows:

Samples

You can define, for example, an event (associated with a button) in a Main Panel object as follows:

Event 'StartTracking'
    Composite
        Maps.ClearLocationHistory()
        Maps.StartTracking(60,100,"",0)
        msg("Tracking Started")
    EndComposite
EndEvent

When defining an Action, you can program an event (associated with a button) as follows:

Main Panel1:

Event 'CallsTrackingPanel'
   Composite
     TrackingPanel()
     msg("Call Tracking Panel")
   EndComposite 
EndEvent

Event 'PositionChange'
   Composite
     &LocationInfo = GeneXus.Common.Maps.GetLocationHistory(&Today)
     SaveTime(...) //SaveTime is a Procedure that stores tracking information in the database
   EndComposite 
EndEvent

The TrackingPanel Panel object should invoke the StartTracking method, for example, in an event associated with a button:

​​​Event 'Tracking'
Composite
     &TrackingParameters.Action ="PositionChange"
     &TrackingParameters.UseForegroundService =True
     Maps.ClearLocationHistory()
     Maps.StartTracking(&TrackingParameters)
     msg("Tracking Started")
EndComposite
EndEvent

The parameters Action and ActionTimeInterval are available for:

UseForegroundService is available for Android since GeneXus 16 upgrade 5.

Warning: The Use Background Location property is mandatory since Android 10.

See Also

HowTo: Solve Tracking with GeneXus
Location When In Use Usage Description property

Last update: March 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant