You need to create a Service that is notified of the updates. Services run in the "background" even when your app is not running. This can get complicated since when a user is in your app, if you expect the app to update, then the activity will need to bind...

I've solved the problem by switching to the Google Play Fused Location provider. A more detailed post around this can be found here: http://stackoverflow.com/a/19282976/3532181 Sadly the standard network provider just seemed too unreliable when it came to updates, ranging from an update within 8 minutes to hours before a new...

You will need to have a foreground service for it to be working all of the time. When the OS is low on resources it may kill background services, which may not start again. To ensure that the service is always running it will have to be started as a...

There are a few approaches. You could have a check within the service that checks the time and registers for location updates when it is within those times, and unregisters when after. This would provide better battery consumption as you say. Or depending on the context you could use the...

It doesn't require GPS to use the network provider, I've done it many times. However, getLastKnowLocation may not return a value if either it has never had an app request updates for that provider, or if the last time that happened was too long ago. You cannot count on that...

Ive done something thats similar to this. Ive solved this problem with intitializing the Location Manager in OnCreate() Method and call in the OnPostExecute() method another method which saves my Current Position to a Variable of type Location. curPos = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); After that you can get the LatLng coords over...

I use something like this in the OnCreate: if(!gpsEnable(myLocationManager)){ // Do something, how to create a AlertDialog or FragmentDialog } Function Code private Boolean gpsEnable(LocationManager locationManager) { return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); } ...

IntentService is a service which remains active as long as it needed. In the GCM case it probably stops itself after processing the message. You can read more about it here.If you register the IntentService as a listener for the location, when the locationManager is trying to invoke the listener...

Yes, essentially this means that if the platform observes your current position as being more than minDistance from the last location that was saved by the platform, your listener will get notified with the updated position. Note that these two positions don't necessarily need to be sequential (i.e., there could...

You have to add these permissions in your AndroidManifest file: <uses-permission android:name="ANDROID.PERMISSION.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> ...

Look at the documentation here. The time is milliseconds, so for 5 minutes minimum, you should write (5mn*60s*1000ms = 300000ms): locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 300000, 0, locationListener); ...

Finally, what I did was using a Runnable inside a Service, and using a ScheduledThreadPoolExecution, as the following way: ScheduledThreadPoolExecutor execUpdateData = new ScheduledThreadPoolExecutor(1); scheduledUpdateData = execUpdateData.scheduleAtFixedRate(new updateDataTask(), 0, sampling_storage_ms, TimeUnit.MILLISECONDS); ...

You can't really create a new instance of GPSTracker and call functions there. Because you've already started the Service. To achieve this, you should implement a ServiceConnection with a Binder. In your Service add, private final IBinder locationBinder = new LocationBinder(); @Override public IBinder onBind(Intent intent) { return locationBinder; }...

getLastKnownLocation returns null if a location hasn't been yet acquired. If it is case for your device, the following snippet if (location == null) { locationManager.requestLocationUpdates(getProviderName(), 0, 0, this); } prevents you from registering the LocationListener, callback for your location manager....

There may be a pretty simple solution and I'm sorry when you've already considered this, but restarting the phone sometimes does the magic for me. A little explanation: I worked for a couple of months on a location aware service and I was stumbling upon those kind of errors as...

I just figured out somthing about this topic and why the addProximityAlert sames to be not working, I'm sharing this with you because I noticed that some people asked the same question before and they don't get any answer! The answer was just in front of me but i didn't...

Well, first off, try looking into the FusedLocationProvider API. This builds upon the new GoogleApiClient and the services offered therein. As far as tutorials go, I'll give you a brief little snippet. The basic concept is that you register a BroadcastReceiver in your application that "listens" for certain services. As...

After an examination of your code, I suggest you two corrections: 1 - Fulfill your criteria. You're passing it empty to the locationManager instance. 2 - Use the LocationListener api to achieve what you want. You can found here some help. EDIT: remove the call of setUpMapIfNeeded() from the onCreate...

Note that you shouldn't be calling getLastKnownLocation() every second if you have a Location Listener set up (which it looks like you do). Just use the latest values given in the onLocationChanged() callback. This code works for me, it registers a Location Listener, which updates the lat/lon member variables, and...

You might want to consider using Network Location as well as GPS Location, as many users just keep the GPS radio off to conserve battery. With Location Services set in "Battery Saving" mode, the device can get accurate geo-location data using Wi-Fi if available. If you use Network Location data...

you are using network location which doesn't provide the correct location rather than using network location you should use the GPS location for current and accurate location. getLastKnowLocation() method doesn't provide the correct , current location for this you can refer this link. rather than using network location use GPS...

You are causing it to stop listening after the first location. public void onLocationChanged(Location location) { if (location != null) { // This needs to stop getting the location data and save the battery power. locManager.removeUpdates(this); <-- REMOVE THIS LINE ...

I just tried this with following permissions: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> and with code: LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); And it took less than 10 seconds to get first location in my balcony, and then it gets updates every second. Thus I don't see the problem...

Thank you for your comments but the solution is to use void android.app.Activity.runOnUiThread(Runnable action) The class GPSTracker does not display the exception, I missed it : Can't create handler inside thread that has not called Looper.prepare() ...

It's safe to leave it registered, it has no effect on battery if you leave it there or register it over and over. from my experience multiply registration to location manager are doing a lot of problems over time, What I would do instead of you is to check every...

You can't do network operations on the main UI thread. What you will have to do is create a new Thread and do the network stuff there. If you need to, you can then you can post updates back to the main UI thread using a Handler. If you need...

You're using NETWORK_PROVIDER when on wifi and GPS when off. Odds are you aren't getting a GPS synch. Its actually very hard to do when indoors. Are you getting a flashing GPS symbol in your notification bar? If so, you aren't getting a full GPS synch and thus onLocationChanged won't...

If you are worried about battery and no so strict on the 10 minutes interval you could try using the PassiveProvider instead of GPS/Coarse. Usually some applications request locations often enough so you don't need to worry about it. If you are strict than you could try to ask for...

String provider; if (isNetworkEnabled) { provider = LocationManager.NETWORK_PROVIDER; } else { provider = LocationManager.GPS_PROVIDER; } is GPS enabled on the device, with Satellite option set in Security section of mobile settings? because you are assuming that GPS_PROVIDER is enabled, just because NETWORK_PROVIDER is disabled? which is not accurate ... also...

From the documentation: Returns the direction of travel in degrees East of true North. If hasBearing() is false, 0.0 is returned. So 0 is north (and the degrees goes clockwise) So 90 would be East 180 South 270 West ...

The delegate method you are using is deprecated. You should use locationManager:didUpdateLocations: and then access the location update from the end of the array - - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { CLLocation *currentLocation = (CLLocation *)[locations lastObject]; ... } It can take some time to get a location fix, particularly...

GeoFenceController will use a global resource - the pool of 20 regions available to your app. That pool is implemented in such a way, that not only a capacity is shared among all the instances of CLLocationManager, all the regions will be effectively shared as well, as all instances of...

Use the new Fused location provider for fetching the location. The Fused Location Provider intelligently manages the underlying location technology and gives you the best location according to your needs. Refer below links: https://developer.android.com/google/play-services/location.html http://javapapers.com/android/android-location-fused-provider/ http://www.kpbird.com/2013/06/fused-location-provider-example.html ...

I tested it on an actual device and it was able to grab my current location. I wonder why the emulator does not function! UPDATE This worked for me: private GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() { @Override public void onMyLocationChange(Location location) { //Do something when location changes } }; Then...