Search code examples
androidgpstracking

RequestLocationUpdates - update location if minDistance OR minTime


I have tracking system and I'm using Android RequestLocationUpdates to get notified about user location changed. Method have parameters minDistance and minTime. Base logic is that notification is called when both of these parameters are met (minTime AND minDistance). I want to get notified for example if minTime OR minDistance is met.

Any solutions?


Solution

  • It is possible and allowed to invoke requestLocationUpdates() multiple times.

    So invoke it one time with your requested minTime and set minDistance to 0, and invoke it a second time minDistance set to your requested minDistance and minTime set to some small value or even 0.

    You can pass the same PendingIntent to both calls.