I have a service which receives locations through registering a LocationManager.requestLocationUpdates.
But there have been some issues on some phones.
When battery runs low, the network location provider stops sending location fixes (this problem is addressed in this SO question). It's not a only a problem with my app but also the other apps just stop receiving locations.
Even when the phone is recharged the problem persists until the full reboot.
However, I found out (and someone also mentioned it in the SO question above) that Google Maps still keeps receiving location updates - when I open Google Maps app it shows the correct location and updates.
So I was thinking about a workaround of using locations from Google Maps API. I have absolutely no experience with the Maps API, but it seems that it needs a proper GUI (Activity) application to be used with. Or am I wrong? Is there a possibility to use Google Maps API to receive locations even within the Service?
Given some extensive testing from a reliable source, I believe that you might want to consider using the FusedLocationProvider supplied with Google Play Services. It seems to take the headache out of choosing the appropriate power criteria and so on.
Be aware that this will require that the user must have Google Play installed on their device, so Kindles and the like will be out of the picture. It also requires a minimum of Android 2.2.
Some more information about the location services provided by Google Play Services can be found here.
Related
I have built an app that triggers geofences defined in the app. But after a restart, it requires me to open Maps for obtaining the current location for it to generate the notification.
Can't post the code due to security reasons. Can someone tell me a way to do whatever Google Maps is doing to do with my app during start up.
I would like to find an API that allows me to pull a client's current location. I know Google Places and FourSquare have API's available. Basically, I want it to run at all times, as I am eventually going to create a dating app that allows you to see who is at a current bar/restaurant/social setting at any given time.
The fetch for the current location will obviously have to be running at all times, and there are considerations of using too many client resources. With that being said, what are some of my options?
Yes, you can use the Google Places API for this: PlaceDetectionApi.getCurrentPlace(). See https://developers.google.com/places/android-api/current-place (and the Getting Started guide).
Ours is a financial app and to curb forgeries we wanted to access users location history from our android app.
The purpose behind this is if the user is requesting the service from a place where he hasn't been often or never been there, we would flag them or ignore them or implement another layer of security.
I have searched and found that google maps maintains location history and google plus may have an undocumented API also.
Please suggest how to get access to location history of device.
That's not possible unless you keep track of the location history yourself.
This may be a kinda odd question but I am new at Android development and I'm having trouble to learn how to retrieve the user's location to my application. I have looked for this topic but I just can't find a statisfying answer.
To get the user location I have found two ways:
http://developer.android.com/training/location/retrieve-current.html . This one is using what I think is the new Google Services release which uses a LocationClient to connect to Google Services and retrieve the location.
http://developer.android.com/guide/topics/location/strategies.html . The other one is using the android.location class and a LocationManager to retrieve the location.
The thing is that I don't get the difference between using one way or the other, which one is better??
And another question is that in the second way you can specify which location provider you want to use, if the GPS provider or the Network provider and in the first one you can't, but in the first paragraph it says that it uses the location sensors that are currently active for the device. Does this mean that I don't have to worry about choosing between both services??
I am using Android Studio and I have set up the new Google Services release, I just need to know the pros and cons between both ways to know which one to use and to begin learning.
Thanks!!
As stated in the second link:
The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy. It also handles location update scheduling based on power consumption parameters you provide. In most cases, you'll get better battery performance, as well as more appropriate accuracy, by using the Location Services API.
I would highly recommend you to watch the last I/O video to get a simple explanation from Reto Meier about the new Location Provider: http://youtu.be/GcNNx2zdXN4?t=14m29s (I suggest you to watch the entire clip btw, it's inspiring).
I am an android developer and have been using it for a while to develop context-aware apps. Location is one of the most important thing for context aware and accuracy of that location is very important.
I know how to get location from GPS using LocationManager... I know how to develop apps using Google maps on android... and also how to display user on the map.. etc. But my friends have found out that when they went to a foreign country for a conference, their location from LocationManager is very inaccurate compare to google maps.
They used my app (not released yet.. ) which I get my location from LocationManager and I registered for GPS and Network provider. If I plot the location that the phone gives me on a map... it's very inaccurate... some times it thinks the user is in Barcelona even though they are at a conference in USA.
Also since the conference was indoor, the GPS wouldn't have helped a lot because it would've had hard time finding a fix.
Does google maps on android get their location similar to how google tells the android developers to get the location... from LocationManager and register for onLocationChanged location listener? If it does... how come theirs is more accurate... how do they filter any outliers? or are they using any internal services to get even more accurate location which maybe google assume that if the developer get that accurate location they could misuse it?
Any ideas or comments??
This code is written by Reto Meier, Tech Lead for Android Developer Relations, who wrote the book on Android App development. Also, that was published in Google IO conference in 2011 as I remember. This is the closest to what is used in Google Places. And it works smart anyway ;)
https://code.google.com/p/android-protips-location/