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.
Related
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.
I would like to know if it is possible to clear the "location" that is stored by play service's fused location API. When testing my app on a real device, I would like to recreate few scenarios and that's the reason I would like to know if this is possible.
I tried to clear "Google Play Services" cache and data. But, it does not seem to help me. Location still seems to be cached somewhere.
I just disabled the GPS then restarted the Android phone & I found that the locationManager.getLastKnownLocation returned NULL for location.
Google Play Services is central service and serves every app installed on your device. After clearing cache and data, if any app connects with Google Play services on that device(which almost every Google app do), then Fused location api will fetch and save location for that app. After that once your app fetches last known location in onConnected, it will return the location.
It is hard to simulate the scenario your are trying to achieve unless you hard code the values to be blank.
Just turn the location off and then turn it on again. It will clear the last known location as it clears all the cached location data on the device.
I have Google Maps installed on my phone and it is usually fully stopped, because I don't want it to always run in the background, since I believe that it is draining the phone battery.
My question is regarding the actual status of the Google Maps app or service.
If you check an app's info there is a button "Force stop". I believe that it is only activated (meaning you can click it) when the app is somehow running.
I noticed that the Google Maps app seems to get started in some way from time to time in the background, because the button gets enabled regularly.
However there is no such entry in the "Running" section for the list of apps in the android settings.
Does someone know whether it is running or not if the button is enabled? Is there some way to check this by code? Is it supposed to be a service or an app?
I have tried using the getRunningAppProcesses and getRunningServices methods of the ActivityManager class, but can't find any entry that would correspond to the Google Maps app. So I guess it is hidden from the user?!
This link may answer your question as to what is the proper way of getting the apps running in background. It suggests that using getRunningAppProcesses and getRunningServices methods are unreliable. Instead, you have to track the visibility of your app on your own via Activity.onPause() and Activity.onResume().
OK, so this is really freaky...
I switch from the old locationmanager to the new shiny locationclient a while back. Works fine, but i noticed a very strange thing while testing fringe settings cases:
As i said, working positoning app using google play's LocationClient as per examples etc.
I start my app, get a couple of positions, all work fine. (You could say that i have a button that fetches locations when you click on it)
I go into settings/location. I disable "Google location services", go back into app, get nothing. I then go back and reenable the setting!
However - i get nothing. ever. Even if i restart my app i never get a location it times out every time.
Only if i restart the phone i start getting positions again.
Anybody have any ideas? Thoughts would be appreciated.
I have a Bike computer app that logs data while the user is riding. I have had a user report an issue I had not considered. He was out for a long ride (100+ miles) but while out and logging data the app got updated via Google plays auto-update. This unfortunately killed off the app mid recording and the user lost data till they spotted what had happened and restarted the app.
Ideally I would like to be able to programmatic stop the auto-update happening while the app is data logging. All my research indicates that this is not possible possible but I may of missed something so dose anyone know of a way of doing this?
Given no solution the best I can do is advice the users to enable the update only over wifi option in the Play app which in this instance would of helped. Unfortunately one of the key points about my app is that it will log indoor sessions using ANT+ sensors so I have a good number of people using it with wifi active.
Edit
I managed to do the experiment to see what happens myself last night. I had an app going in the background data logging then pushed a new version to Google Play. Unfortunatly it was not picked up totaly automaticaly when I had to leave 10 hours latter but I opened up the play store app and it found the update it did not start updating automaticaly but I forced it. The act of downloading and installing the new version killed off what was in progress. It was already dead before I used the notification to go to the new version.
As you say yourself, you can't do that what you are asking for. You could hack your way around it by changing the permissions each time you update. The users will then be prompted about it in the regular way.
I'm not sure about the "life-cycle" for automatic updated apps that are running. But I read somewhere that is wasn't the re-install but the reopen of the app that crashed it. If that is the case you could set a flag indicating that the user is currently logging and then on restart just resume the logging. But again we need to know more about the inner workings of activities/apps which are running and get an automatic update (actually didn't think it could happen).
Edit
Based on your findings I'd say you have to handle the app is shut down in onDestroy etc. or/and make sure you save everything persistently. Then you might need to have 2 apps where 1 listens to the other being re installed and when that happens it starts it up again (there is an interesting discussion here). If you are targeting api >= 12 then the broadcast action ACTION_MY_PACKAGE_REPLACED might also have interest.