Clear fused location provider's location for testing - android

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.

Related

Is Google SDK handle the background location?

I am working on ride hailing app. I am getting location in the background after every few seconds. To get location, I am using Foreground Service. It is working fine.
But on some devices, there are different types of options to control the Background power consumption. If these options are enabled then these devices will freeze/terminate may app and foreground service too.
Due to which My app will not update the location.
Is there any solution to get location or not in this case?
For further details. please have a look on this link
FurtherMore, my second question is that if I will use Google SDK for this purpose, will google handle this or not?
If I use google sdk then will google sdk be responsible to get location in each scenario or not?

Google API GPS location Android available to all activities

I am able to get the user location by using Google API and Location services. That location is then saved to an online database. However, how would I go about making the location update every X amount of time (lets say 10 minutes). Also, the Google API and location services is linked specific activity. How would I make the location services available to all activities, meaning that once the user is logged in, no matter what activity the user is in, the location would be updated and saved to my database? Finally, if the phone is in sleep mode or the app is running in the background, would the location still be updated?
Thanks, any suggestions or pointers are appreciated!
It is a duplicate question.
There are many solutions.
I recommend to you read following question.
Example: Communication between Activity and Service using Messaging

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.

Android GPS battery usage

I am writing a program in Android that uses GPS. It will prompt the user to turn on location services if it is not on (which I guess is equivalent to turning on gps ?). My question is: does the gps immediately start consuming extra battery power as soon as location services is turned on or it uses batter power whenever the location services is queried/used for a new location ?
The GPS starts working only when the location manager requests an update from it. Turning on the GPS in the device only allows programs to request locations if they want, but it doesn't mean the GPS is kicking in.
You can test it yourself: The GPS icon in the notification bar tells the GPS status. You can turn on the GPS, but the icon won't appear. Why? No application requests updates now. As soon as an application requests an update, the icon starts blinking (The GPS is initializing itself) and when it stops, it means the GPS is initialized and is currently receiveng updates.
The GPS consumes battery only when this icon appears.
My company wrote a blog post on this subject a while back. Check to see if its useful.
http://www.littleeye.co/blog/2013/03/29/understanding-gps-resource-usage/
But we missed talking about what happens when no app is actually requesting for a location update. And yes, as mentioned unless apps actually ask for a location update, they will not cause power drain. But note that even a single request for a location update (depending on coarse or fine grained request) can have unintended effects, as the device has to go thro various states before it can get back to its steady state.
Turning on location services is just permission given by user to applications for using location services. As long as any application not asks for location, power consumption is the same as with location sesrvices turnded on.
On the other hand - there is many applications trying to get location. Facebook, Camera, Android, many of ads libs, so yes - user can get battery life issues when GPS is unlocked.

Android Location from Startup

i am currently developing an app that requires location from the start. I have a method that checks if location updates are up, but even when GPS is turned up I cant ensure a Location Update when the app starts. How can I ensure a fresh location update when my app starts?
i am currently developing an app that requires location from the start.
That is a design flaw in your app. Please redesign your app to take into account that:
the user may have GPS disabled, or
the user may not have used GPS recently, so it will take some time to acquire a fix, or
the user may not be in a location where GPS signals are available (e.g., inside a large building)
How can I ensure a fresh location update when my app starts?
You can't.

Categories

Resources