Document Navigation SDK for Android Guides Location Location Updates and Callbacks

Location Updates and Callbacks

The Navigation SDK relies heavily on location services. When you initialize AMapNavi, the SDK automatically starts location updates internally, with a default interval of one second. If you need to control the location update frequency, use the following APIs. For optimal navigation performance, a one-second interval is recommended.

Configure Location Updates

Use the startGPS and stopGPS methods to manage location updates.

/**
 * Starts GPS positioning with time and distance parameters.
 * <p>
 * You can manually start GPS positioning. If GPS is not started, it will
 * be automatically started when driving or walking navigation begins
 * (startNavi).
 * </p>
 *
 * @param time The time interval for location updates, in milliseconds.
 * @param dis  The distance interval for location updates, in meters.
 * @return Returns true if GPS started successfully, false otherwise.
 */
@Override
public boolean startGPS(long time, int dis)

/**
 * Starts GPS positioning.
 * <p>
 * You can manually start GPS positioning. If GPS is not started, it will
 * be automatically started when driving or walking navigation begins
 * (startNavi). The default location update interval is 1 second, and the
 * default distance change is 0 meters.
 * </p>
 *
 * @return Returns true if GPS started successfully, false otherwise.
 */
@Override
public boolean startGPS()

/**
 * Stops GPS positioning.
 *
 * @return Returns true if GPS stopped successfully, false otherwise.
 */
@Override
public boolean stopGPS()

Location Callbacks

Location-related callbacks are defined in the AMapNaviListener interface. Detailed location information is provided in the AMapNaviLocation object.

/**
 * Callback when the GPS location is updated.
 *
 * @param location The current location information.
 */
void onLocationChange(AMapNaviLocation location);

/**
 * Callback indicating whether the user's device GPS setting is enabled.
 *
 * @param enabled true if GPS is enabled; false otherwise.
 */
void onGpsOpenStatus(boolean enabled);

/**
 * Callback when the satellite signal strength changes.
 *
 * @param isWeak true if the signal is weak; false if the signal is strong.
 * @since 7.5.0
 */
void onGpsSignalWeak(boolean isWeak);

Network-Based Navigation

Starting from SDK v7.5.0, the Navigation SDK fully supports network-based navigation. No additional configuration is required — simply upgrade to the latest SDK version.

Location signals can be categorized into satellite positioning and network positioning, with accuracy decreasing in that order. Navigation relies heavily on precise positioning, but some areas — such as near tall buildings in cities or under overpasses — may not receive high-accuracy satellite signals. In such cases, network positioning signals assist navigation. Network-based navigation acts as a compensatory mechanism, providing more accurate navigation for users in areas with weak positioning signals.

To determine whether the current location is from network positioning, use the getLocationType method in AMapNaviLocation.

/**
 * Returns the location method used.
 *
 * @return 0 for GPS positioning; 1 for network positioning.
 */
public int getLocationType()