-3

I want to get current GPS location of my device when button is clicked. I don't want my app to continuously check for location updates. So is there any way to get current GPS location of device only when button is clicked and stop using GPS after that?

mattm
  • 5,851
  • 11
  • 47
  • 77
Raees Khan
  • 371
  • 1
  • 5
  • 20

1 Answers1

0

Yes, this is quite straightforward. If you take a look at the developer documentation, you simply request to "Stop Location Updates" once you have a location. In the example, you would call stopLocationUpdates in onLocationChanged.

mattm
  • 5,851
  • 11
  • 47
  • 77