question: private void onLocationChangedAsync ( Location location ) { try { if ( ! isRecording ( ) || isPaused ( ) ) { Log . w ( TAG , "Ignore onLocationChangedAsync. Not recording or paused." ) ; return ; } Track track = myTracksProviderUtils . getTrack ( recordingTrackId ) ; if ( track == null ) { Log . w ( TAG , "Ignore onLocationChangedAsync. No track." ) ; return ; } if ( ! LocationUtils . isValidLocation ( location ) ) { Log . w ( TAG , "Ignore onLocationChangedAsync. location is invalid." ) ; return ; } if ( ! location . hasAccuracy ( ) || location . getAccuracy ( ) >= recordingGpsAccuracy ) { Log . d ( TAG , "Ignore onLocationChangedAsync. Poor accuracy." ) ; return ; } if ( location . getTime ( ) == 0L ) { location . setTime ( System . currentTimeMillis ( ) ) ; } Location lastValidTrackPoint = getLastValidTrackPointInCurrentSegment ( track . getId ( ) ) ; long idleTime = 0L ; if ( lastValidTrackPoint != null && location . getTime ( ) > lastValidTrackPoint . getTime ( ) ) { idleTime = location . getTime ( ) - lastValidTrackPoint . getTime ( ) ; } locationListenerPolicy . updateIdleTime ( idleTime ) ; if ( currentRecordingInterval != locationListenerPolicy . getDesiredPollingInterval ( ) ) { registerLocationListener ( ) ; } SensorDataSet sensorDataSet = getSensorDataSet ( ) ; if ( sensorDataSet != null ) { location = new MyTracksLocation ( location , sensorDataSet ) ; } if ( ! currentSegmentHasLocation ) { insertLocation ( track , location , null ) ; currentSegmentHasLocation = true ; lastLocation = location ; return ; } if ( ! LocationUtils . isValidLocation ( lastValidTrackPoint ) ) { insertLocation ( track , location , null ) ; lastLocation = location ; return ; } double distanceToLastTrackLocation = location . distanceTo ( lastValidTrackPoint ) ; if ( distanceToLastTrackLocation > maxRecordingDistance ) { insertLocation ( track , lastLocation , lastValidTrackPoint ) ; Location pause = new Location ( LocationManager . GPS_PROVIDER ) ; pause . setLongitude ( 0 ) ; pause . setLatitude ( PAUSE_LATITUDE ) ; pause . setTime ( lastLocation . getTime ( ) ) ; insertLocation ( track , pause , null ) ; insertLocation ( track , location , null ) ; isIdle = false ; } else if ( sensorDataSet != null || distanceToLastTrackLocation >= recordingDistanceInterval ) { insertLocation ( track , lastLocation , lastValidTrackPoint ) ; insertLocation ( track , location , null ) ; isIdle = false ; } else if ( ! isIdle && location . hasSpeed ( ) && location . getSpeed ( ) < MAX_NO_MOVEMENT_SPEED ) { insertLocation ( track , lastLocation , lastValidTrackPoint ) ; insertLocation ( track , location , null ) ; isIdle = true ; } else if ( isIdle && location . hasSpeed ( ) && location . getSpeed ( ) >= MAX_NO_MOVEMENT_SPEED ) { insertLocation ( track , lastLocation , lastValidTrackPoint ) ; insertLocation ( track , location , null ) ; isIdle = false ; } else { Log . d ( TAG , "Not recording location, idle" ) ; } lastLocation = location ; } catch ( Error e ) { Log . e ( TAG , "Error in onLocationChangedAsync" , e ) ; throw e ; } catch ( RuntimeException e ) { Log . e ( TAG , "RuntimeException in onLocationChangedAsync" , e ) ; throw e ; } }
target:  Called when location changed.