Android Geofence Delay (10-20seconds) - android

I have built an Android app with Geofences following the instructions from the developer training. I have tested my app several times during the production proccess with mock locations - it worked like a charm. However, when i tested my app with real location data (always with GPS enabled) the app showed a delay of 10-20 seconds after entering or leaving a geofence. My first thought was that the GPS signal might be inaccurate. But I later added Google Maps to my app and I can now see the accuracy of the GPS-signal according to the circle around my current location - all should be fine.
Has anybody faced a similar problemor know how to fix it?
Thanks

Related

Recent changes in Location manager behavior?

I develop a running app that use GPS location through LocationManager to deliver a Turn by Turn navigation experience.
Yesterday, ï discovered that I do not receive any location updates when app in background (phone locked) anymore.
This could not be a code regression because none of my previous git commit work neither. And I know I could receive location updates during last tests few weeks ago.
Then I tested other GPS-based app like Waze and others, but same result : none of them could update my position when going in background (except for GMaps), meaning I have no navigation instruction if my phone is locked. I have tested with other phones Samsung S8, S9, and Asus ... no changes.
Does anybody know if there was a recent changes in LocationManager behavior?
Thank you.
I found a good workaround.
In order to receive GPS location while in background with Android 8.0, we need to create a foreground service that ask for location update and pass it to your activity.
Here is an example of that.

Having issues testing location services. I can't make them NOT to work

I implemented getting location updates using FusedLocationProviderApi.
I need to track device location in background, when app is not running.
I followed the tutorials, I have a Service where I call requestLocationUpdates with an intent which starts a service.
I've purposely NOT implemented keeping a wake lock just to test and see that when the screen goes off, the device stops getting location updates. Once I verified that I could then go and implement the wake lock and expect the opposite, which is to see it working.
I used two devices: a Google Nexus 10 with KitKat and a Samsung Galaxy A5 (2016) with Lollipop.
On both devices, it keep sending updates (I'm sending the updates to a website).
I tested with screen off, after leaving device on a desk for a minute, and then walking again around the house.
I know Android 6 and Doze mode is more restrictive, but I want to nail and understand how it works on Android 4.4 and Android 5.
So frustrating! Any ideas how to actually make device go in sleep mode so I can see getting location updates stop working?
Funny, everything I've read is about making it work :)
EDIT: I'm confused why getting location updates is still working when screen is off even with an aggressive location update setup like the following:
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setFastestInterval(2);
locationRequest.setInterval(1000);
Thing about requesting location updates is that underneath it all, the LocationManagerService, which is what LocationManager uses, actually creates and acquires it's own wakelock. So technically, your device will never go to sleep as long as you have a location listener registered to actively receive GPS. Now, I know you are using Google's FusedLocationApi, but underneath it all, it does use LocationManager. If you are interested in understanding the location code a little better, here is the source code for LocationManagerService.

Android Fake GPS location apps do not work anymore

I used to work with this application:
https://play.google.com/store/apps/details?id=com.fakegps.mock&hl=en
And before this with this one:
https://play.google.com/store/apps/details?id=com.incorporateapps.fakegps.fre&hl=en
Am working on a LG G3 and a Nexus 5, but in the last couple of days, the fake location doesn't work as it should.
It doesn't always modify my location and sets in where I want. Or many times, it sets my location where I want for a couple of seconds and then resets to my real location. I'm working on a travel app, and this made it very simple to simulate trips and locations.
Is there any other fake location app that actually works how it should?
Or is there any other way to set the location of my phone, while the app is running?
EDIT: YES! MOCK LOCATIONS is ON.
Like i said: It DOES change my location, to the mock location I want, but it jumps back to my REAL location, after a couple of seconds. Depending, sometimes, it stays for minutes on the mock location, but then jumps for 1 second on my real location, and then goes back :)
Now I know this, cause I log all the locations that I find, even more, draws the path, and I have lines that jump back to my Real location and then continue
PICTURE: Pink = how it should be.
Green = locations that I get and the path. As you can see, each a couple of locations that I get, it jumps back to my location
https://www.dropbox.com/s/sszzrvhnwlq2bxr/Screenshot%202015-09-10%2015.47.20.png?dl=0
If mocked location seems to jump to real one during simulation, try to turn off wifi based locations (Settings / Location / Mode --> Device only).
Make sure you have Allow Mock Location turned on in phone's Developer Options and try this app: https://play.google.com/store/apps/details?id=fr.dvilleneuve.lockito&hl=en
I'm using it when working on Geofencing and works great.
I managed to fix this problem by disabling the "Fused Location" service on my phone. I used the Disable Service application which requires root privileges to run. After disabling the "Fused Location" service I stopped teleporting to my real location.
In Settings -> General -> Location -> Mode
I switched it from Battery Saving to High accuracy and then the mock location app started working.
Note, you also need to set your preferred Mock Location app in Developer Options, but even after doing that my app was showing my true location instead of the mocked location - now it's working like a champ!

Android Geofencing sample app only works if another app is open using GPS

I am working with the Geofence API Sample application I've got it running and seems to work alright. I did make the modifications to it to use BroadcastReceiver instead of the IntentService.
But I will only get the notifications if I have some other app open that is using GPS such as Maps, or GPS Tester app.
If I don't have one of those apps open and I walk into the geofence zone nothing happens. But as soon as I launch one of them I will get the notification within a few seconds.
I ended up creating a service that forces the GPS to stay active by requesting location updates on a relatively quick interval.
While this is admittedly a poor work around for a "real" application. It worked for my purposes. In which I needed to be able to present a working proof of concept to an audience, which impeded my ability to use a geo points which were further spread out.
Even I too had a struggle with getting Geofence notification as soon I entered Geofence or Exit the one.There were always delays in notifications until I found a really nice Location Library called little-fluffy-location-library which serves my purpose.Location updates will be broadcast to your app periodically.
According the Documentation it says that:
The library works by using Froyo's passive location listener (only possible with Android 2.2 and up, hence why it works best with it), which listens to location updates requested by other apps on your phone. The most accurate location is broadcast to your app approximately every 15 minutes. If a location update hasn't been received from another app for an hour, the library forces a location update of its own.
I think you should give a try with this Library and Let me know if it works for you!!

Google Play Services location not available after location restart

We have location updates from play services in an app. If I got into settings, turn off location, then turn it back on, we no longer get updates. The gps icon turns on, but nothing comes to the app. After that happens, I actually need to reboot the phone.
Haven't seen anything online about this, but I also tried a basic example (ie. not our app), and the same happens.
Running Nexus 5, kit kat. Services 'version' 4132500.
Can't find anywhere to post bugs, so we'll post here and see what happens.
Update. Found a little more info. If I got into settings, apps, running, and force stop "Google Location Services", location apps will work again.
Also, to show more clearly that this isn't just an issue with my app, I test this using google maps.
I suspect the running location service figures out when location has been turned off, but doesn't figure out its been turned back on. Any way to submit a bug?
Heard from the google people that this is a known thing and will be fixed in March at some point.

Categories

Resources