Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fused Location sometimes STOPS

I've been working on an app that tracks the user's position. For this I have used the google play services location module (a.k.a. fused location). All in all everything works fine.

BUT sometimes, completely random, I no longer receive location updates from the google location services, at all! I mean, my app is working fine, but no location updates. Not only that,if I start up google maps it can't get a fix on my location (even with GPS turned on). Reinstalling my app doesn't fix the issue. Out of the 3 taxi apps that I have on my phone, 2 of them can pinpoint my location. (Most likely they are using the old LocationManager to get the device's location).

I found that to fix this issue I have but to restart my device. But this is very unsettling, I can't expect my users to restart their devices whenever something goes wrong with the location updates. (though this has only happened to me about 6 times in the past 2 months)

So: Does anyone know about this issue and is there a work-around for it? Is my app somehow crashing google play services?

like image 952
Sebek Avatar asked Oct 21 '22 09:10

Sebek


2 Answers

I have found that if you don't unsubscribe from the LocationManager by calling removeUpdates on app close, it will sometimes cause the issue you are experiencing.

like image 66
Nyx Avatar answered Oct 23 '22 03:10

Nyx


I have recently experienced the same problem, Sebek. I do not believe the answer NYX gave is the correct one. There seems to be some other fix for the problem that only Google knows. Why do I say this?

I have created an app that uses Fused Location Services to get the location of the mobile device at 30 second intervals and toast the position when the app is in focus. But for some reason the Fused Services just stopped working. I tried again and again and again...switched on all location services - WIFI, GPS and Network...nothing worked. The Fused Location services remained off.

But then I tried something...I started up my app and then using the inbuilt Android Task Manager I launched Google Maps...and BOOM! The Fused Location Services on my app worked and started reporting location data on the 30-second mark everytime...and for some weird reason the accuracy of the locations was also improved...up to 5 metre accuracy!! I tried the same procedure over and over - first launch my app and nothing...then launch Maps and BOOM! - it worked everytime. A 100% success when I launched Google Maps.

So this is clear proof that Google is running some code that ensures the Fused Location Service doesn't drop out when Google apps are launched and needs the location service. Sebek, maybe you can try this and see if you get the same results. Maybe then we can progress somewhere in finding a true fix.

Cheers, Shore-T ...

like image 29
SilSur Avatar answered Oct 23 '22 03:10

SilSur