GPS stops retrieving recent updates - android

I'm having a problem with a few users that their gps tracking app stops updating their position, and keeps sending old position to our backend.
The implementation was based on FusedLocation tutorials, and it works. It is just that, with a few people, it suddenly stops working.
Not sure if it's related, but what happens if I try to get a position while the last try is still trying to get (with the gps icon still blinking)?
The only hint I know is that when I disconnect and connect again to the GoogleApiClient, the gps works fine again. Does anyone also know anything that might be causing it?
I'm using Play Services: 7.5.0
Edit: The interval between each gps request is 30 seconds.

Related

[Android]: Some questions about GoogleFusedLocation API

I'm currently working on an Android app that use location to operate. Imagine that when you run app, it will display all near-by hotel.
After reading the Internet, I applied Google Fused Location to my app but some problem occurred and I have no idea how to solve it.
Here are my approach:
When SplashActivity start, I run the LocationService to create location request and request location update. I use HIGH_ACCURACY option and use both GPS and Network Provider.
In onLocationChanged() I call Geocode Intent Service to parse lat lng to address.
When Geocode Intent Service complete, I receive the result thanks to ResultReceiver (I did the exact same way like Google tutorial) and send a Broadcast to SplashActivity.
When SplashActivity receive broadcast, I start my MainActivity.
Please let me know if my approach is a correct way to use FusedLocationService, this is the 1st time I make location-based app.
Sometime, onLocationChanged() took so long to response (about 3 minutes, sometime forever). I notice that this problem occurred only on Android OS 5, 6, 7 (I do request permissions) but again sometime it really fast (1-2 secs). This problem is killing me, I have no idea how to solve this.
I'm thinking about apply last known location to solve the above problem, but I wonder if there is a way to set a time-out for requestLocationUpdate(). And my app need user current location to display data, so I don't think last known location is a good idea. Anyway, it's good to hear your opinion about this.
Thanks for reading.
Firstly, considering a location is fresh or old could depend on your scenario. I meant, a ten minutes old location maybe useful for weather app, but doesn't sound good for tracking intent.
IMHO, the whole process seem a bit bad, you can give chance to receive location for user even after splash screen
Anyways, i have a scenario for you
Define a timeout value, for instance 10 seconds
Make location request with immediately values (set interval and fastest interval 0)
If you receive location, remove location updates, stop timeout and use location (for geocoder)
We couldn't receive location and timeout finished, refer to last known location
If the last known location is nice for us(mentioned in first paragraph) use location (for geocoder)

How to check if your location has been confirmed in Android?

I'm building an app that involves getting the user's current location. I already have it getting the location, but sometimes it's inaccurate.
I've noticed that when I start the app, a location services symbol appears greyed out in the notice bar. While it's greyed out my app will sometimes report that I'm where I was an hour ago, even if I'm miles away. A few moments later the symbol will be solid and then the app reports the correct location.
The phone seems to understand that it's not entirely sure for moment. Is there a way to check this programmatically?
I'm aware of how to check if location services are enabled. The problem is that my location is not updating quickly enough and I'd like to wait until the phone is absolutely sure of where I am.
My current fix is to make a fake loading screen that just forces the user to sit for a few seconds, but this seems a bit sloppy. Also, I have no guarantee that the location will have updated properly by the end of the three seconds.
I'm trying to avoid making the app run in the background and check periodically because I'm worried about draining the battery.

Weird issue with GPS in my Android app

There seems to be a problem with the communication between GPS and my android application.
About 1 in 10 times (after starting the application) the GPS isn't triggered by LocationManager.requestUpdates() (no GPS icon shows up etc.).
I've built in a timer that checks the GPS status every 15 seconds and when the GPS isn't working it'll remove the updates from the LocationManager and requests the updates again (the GPS status is checked through GpsStatus.Listener). Sometimes this wakes up the GPS and the problem is solved, but most of the time this doesn't work. However, turning off GPS on the device and turning it back on [sometimes] fixes this as well.
The application has lots of users with different devices who have this problem. I have a foreground service running at all times which requests these location updates in onStartCommand() and it removes the updates in onDestroy(). I've tried a lot of different solutions, but none of them seem to work (frustrating). I tried the fused location provider, but this doesn't always give the most accurate location/has no bearing/speed etc. Is there any other way to give the GPS a poke to wake it up or has anyone had this problem before? Also, I noticed that whenever this happens and I close the application, remove it from memory, and start it up again, the problem is fixed as well. It looks like something in the application is blocking it from communicating with the GPS (no idea if this is possible).
I'm curious if anyone has any suggestions as to what the problem could be.
Thanks in advance,
Wow, so I've been frustrated with this issue for a couple of weeks and apparently it's because of Flurry. Flurry reports GPS locations as well and this conflicts with the GPS of my app.. Calling FlurryAgent.setReportLocation(false) fixed this issue for me.

Requesting location updates while Google Maps Navigation is actively running

I would like to request location updates from LocationManager using the GPS provider only. I understand that doing this does not immediately return location results.
However, let's assume that the user is currently running the Google Maps Navigation app (i.e., there is an active route) and their GPS signal is strong. Would requesting the GPS location yield a result quickly due to the fact that it is constantly being fixed? Or am I making an invalid assumption?
Furthermore, if I were to call getLastKnownLocation(LocationProvider) while the Navigation app is running, can I assume the last known location will be very close to the current location? How often is the last known location updated when the Navigation app is actively navigating?
Thanks so much!
Would requesting the GPS location yield a result quickly due to the fact that it is constantly being fixed? Or am I making an invalid assumption?
Furthermore, if I were to call getLastKnownLocation(LocationProvider) while the Navigation app is running, can I assume the last known location will be very close to the current location?
If you have a Service that listens for GPS updates, you will have access to the most recent data returned for any application. I recommend using the PASSIVE_PROVIDER which will receive updates from any provider as they arrive.
I get the GPS fix in my HTC Incredible within 30 secs, regarding your question I tried opening the Navigation app and my application, I dont see any difference if I am running just my application alone.
Would requesting the GPS location yield a result quickly due to the fact that it is constantly being fixed?
The GPS yield a quick fix that depends based on the Satellites.

Network provider stops providing updates

I have noticed that rarely (every few days), my app stops receiving new location updates.
The location listener is registered with both network and GPS providers. The GPS provider is off so any location updates come from the network provider. Every few days or so, I notice the location is old and not updating. From my debug log I can see that the location listener is being registered with location manager but there are just no new locations being found. onLocationChanged() is not called.
The strange thing is, Google Maps has no problem getting a new network location. Restarting/reinstalling/clearing data on the app does not solve the issue. The only thing that solves it is to restart the phone.
This has happened on 3 different devices (2 ICS, 1 JB).
Similar problem but not worded very well here.

Categories

Resources