gps location on button press

greetings fellow coders.
i’m doing a project that involves gps locations, and im trying to get my current location on a button press.
but i can’t seem to get that working. i’ve tried a few ways to do it, but none of them works.
the thing is i dont need to know the location until the button is pressed and there is no reason for the app to unnecessary try to pinpoint the location from the start of the scene.

so my question is, is there a way to start the gps tracker on a button press, and get the longitude and latitude from where the user is when pressing the button, and then only update when the button is pressed again?

The problem is that it takes time to turn on the radio, acquire at least 3 GPS satellites and figure out where you are.  This is not something you can hit a button and get an instant response.  If you want that, you have to turn the GPS on before and let it acquire everything then the button press can get the information on demand.

Rob

i made a workarround with the button, but i came across another problems afterwards.
it seems that i will only give me a precise location with gps, if i use wifi or mobile data the point is fixed to a place where i’m not and stay there even if i move.

edit: and is there a way to check if gps is enabled, so the user can get a message to turn it on to use the service?

The problem is that it takes time to turn on the radio, acquire at least 3 GPS satellites and figure out where you are.  This is not something you can hit a button and get an instant response.  If you want that, you have to turn the GPS on before and let it acquire everything then the button press can get the information on demand.

Rob

i made a workarround with the button, but i came across another problems afterwards.
it seems that i will only give me a precise location with gps, if i use wifi or mobile data the point is fixed to a place where i’m not and stay there even if i move.

edit: and is there a way to check if gps is enabled, so the user can get a message to turn it on to use the service?