I have built an app where in you take pictures and GPS data of that picture is captured for GPS I implemented service and implemented location listener for it. Its working fine but it drains battery so I am planning to change a Lil bit I will start the GPS service when user decides to take pic in my app.. And remove the listener on picture taken. This works fine provided the button to capture is taken after the GPS search is finished else GPS data accuracy is not there. So I have thought to show a dialog fragment to user saying GPS is initializing and ask user to wait. And once GPS location is set the dialog fragment should disappear and user must be able to take picture by the button provided. My problem is how do I capture the event That GPS search is completed .. I am using built in GPS satellite.
Related
When I open my home page I want to get longitude and latitude of the device currently situated in, so I can display current whether in homepage. Using GPS it works well but I want to get long. and lati. as soon as I land on homepage without having a user turn on the GPS is there a wayout for that??? as just for whether user has to open gps and then access it and my app is not whether based app.
Location data is required for LatLng to work properly. I would suggest prompting the user to turn their location data on when they open the app if it's off.
I am developing an app who makes basically the following things: when the GPS is enabled it takes the current position and calculates the distance between the location took from the location manager and a fixed position, then when the distance is lower than a value, for example 10 meters, the app automatically open another Activity containing the informations about the location reached, the problem is that when the user is visualizing the info page he remains in the range and the previous activity continues opening the same activity with informations, how can i prevent this problem? I need to stop the method that open the new Intent when the info are visualized and then restart when the user is back in the distance calculation Activity.
The concept is called proximity alerts. May be you have implemented this on your own and which is not working properly. Look into the implementation of Proximity Alerts. Moreover this will have two notifications when user enters into range and when exits from the range.
I am making a small app, when the user clicks the button the app gets the users location and opens Google maps.
The problem is, if the users mobile doesn't have GPS enabled , then enables it and clicks the button again, this method will return null:
location = service.getLastKnownLocation(provider);
When I wait after enabling GPS and then click the button, the method will work correctly and return the location.
How can I solve this problem?
why need to wait some second after enable GPS,to work?
It's because when you enable GPS it'll fix position of Satellite and based on that you'll able to get Location.
It is obviously a default behaviour, when you stop GPS and start it again, there is a small gap between start and stop, at that point, GPS will do its task, to get satellite data and after that it will provide you location. If we want to drive fast then we must need to start from 1st gear, same behaviour GPS doing.
As the answers mention above, the device will get the location after a while. If you are in the middle of a flow, you can show a ProgressSpinner and poll getLastKnownLocation() for x seconds to get a location.
If you hadn't used GooglePlayServicesClient try this to get user location.
It is the fastest way to get current lat long.
For reference and code use the following link.
http://developer.android.com/training/location/retrieve-current.html
Hop i helped you.
i have an app that takes the user exact GPS location and save it to a database when he presses a button.
i need his exact location(i.e location that is Fixed with GPS)
i used onLocationChanged() and GPS_EVENT_FIRST_FIX, but the problem was if the user was standing still and already had a fix, then he pressed a button, the app would wait as it neither of the above will launch.
and i was wondering if there was any way i can check if the GPS already has a fix on the device's location.
In my android app, the user is able to turn off the GPS.
Because I need sometimes of the GPS and I want also ask the user to turn on the GPS again.
But the user is able to mark for not appears more this warning.
Use LocationListener which has the method onProviderDisabled. This method gets called everytime the user turns off the GPS provided you have set the Location Provider to be GPS.