Network_Provider Not Providing Updated Locations

Network provider not providing location updates

For network based location, they are a lot less inaccurate than GPS, meaning you need to move the device a much larger distance to allow the signal to hook on to another network tower before
onLocationChanged() is called. Also not all network towers provide location.

NETWORK_PROVIDER is not giving location updates

To ensure if the NETWORK_PROVIDER is operational check like this,

if(isLocationProviderEnabled(LocationManager.NETWORK_PROVIDER))
{
Log.i("PROVIDER", "ENABLED");
}

LocationManager.NETWORK_PROVIDER is not triggering onLocationChanged in ICS

This is known issue:

After device reboot the network location provider works fine but after some time it stops updating.

https://code.google.com/p/android/issues/detail?id=57707

Unfortunately without solution yet.

NETWORK_PROVIDER not Working in android

Instead of using the legacy LocationManager, you should use the Google's new Fused Location API connecting to the Google Play Services, you can get the lastknown and current location, here is how to get the lastknownlocation:

 protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}

public class MainActivity extends ActionBarActivity implements
ConnectionCallbacks, OnConnectionFailedListener {
...
@Override
public void onConnected(Bundle connectionHint) {
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient);
if (mLastLocation != null) {
mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude()));
mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude()));
}
}
}

For more details check official example here

And in your Manifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms.location.sample.basiclocationsample" >

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>

Android: LocationManager service stops updating when set to NETWORK_PROVIDER

I've solved the problem by switching to the Google Play Fused Location provider. A more detailed post around this can be found here: https://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 update was sent to the app.



Related Topics



Leave a reply



Submit