Get and store GPS location with button press

I was wondering if there is an easy way to get the location of the user when button is pressed. From what I have seen it can only be done by using a listener.

Thanks!

No matter what you do, you’re going to have to enable location services and that’s going to have to have a listener function. It’s going to get an event whenever the GPS triggers and you’re listener function can set variables that your button handler can later pick up.

Rob

Ok thanks,

Is there a way to reliably make the GPS trigger? I have noticed on the simulator that sometimes it will trigger once and other times it will fire off multiple times very quickly and then does nothing. 

Would the GPS start to trigger if I put the app on a device and started moving around?

You shouldn’t be getting GPS in the simulator. If there is any location services working, it’s just picking up your WiFi info which isn’t very accurate.

Rob

ok, thanks for your help. It did seem to trigger consistently while on a device. Using the idea you suggested above I have managed to get everything working.

Thanks

No matter what you do, you’re going to have to enable location services and that’s going to have to have a listener function. It’s going to get an event whenever the GPS triggers and you’re listener function can set variables that your button handler can later pick up.

Rob

Ok thanks,

Is there a way to reliably make the GPS trigger? I have noticed on the simulator that sometimes it will trigger once and other times it will fire off multiple times very quickly and then does nothing. 

Would the GPS start to trigger if I put the app on a device and started moving around?

You shouldn’t be getting GPS in the simulator. If there is any location services working, it’s just picking up your WiFi info which isn’t very accurate.

Rob

ok, thanks for your help. It did seem to trigger consistently while on a device. Using the idea you suggested above I have managed to get everything working.

Thanks