Location updates are not regular

I am developing a distance app that requires regular distance updates, the app works fine if the device has internet, but if the device has no connectivity in this case, even if the GPS is on and I move, it does not update the location in the OnLocationChanged Listener as necessity

Registering a Location Receiver

LocationListener[] mLocationListeners = new LocationListener[]{
        new LocationListener(LocationManager.GPS_PROVIDER),
        new LocationListener(LocationManager.NETWORK_PROVIDER)

 mLocationManager.requestLocationUpdates(
                LocationManager.NETWORK_PROVIDER, LOCATION_INTERVAL, LOCATION_DISTANCE,
                mLocationListeners[1]);

      

LocationListener

private class LocationListener implements android.location.LocationListener {
    Location mLastLocation;

    public LocationListener(String provider) {
        Log.e(TAG, "LocationListener " + provider);
        mLastLocation = new Location(provider);
    }

    @Override
    public void onLocationChanged(Location location) {
        Log.e(TAG, "onLocationChanged: " + location);
        mLastLocation.set(location);
        mLocationController.updateLastKnownLocation(location);
    }

    @Override
    public void onProviderDisabled(String provider) {
        Log.e(TAG, "onProviderDisabled: " + provider);
    }

    @Override
    public void onProviderEnabled(String provider) {
        Log.e(TAG, "onProviderEnabled: " + provider);
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        Log.e(TAG, "onStatusChanged: " + provider);
    }
}

LocationListener[] mLocationListeners = new LocationListener[]{
        new LocationListener(LocationManager.GPS_PROVIDER),
        new LocationListener(LocationManager.NETWORK_PROVIDER)
};

      

I am using this location receiver

+3
android gps location android gps


source to share


No one has answered this question yet

Check out similar questions:

757
What's the easiest and most reliable way to get the current location of a user on Android?
683
How to get current GPS location programmatically in Android?
4
Getting Android location over Wi-Fi only doesn't work
3
Problem: while stationary Android GPS gives different location updates - closed
3
Fused Location provider should call onLocationChanged () only when user location changes
2
Listening to an anchored location service from an activity
2
Android GPS location receiver not working in any device
0
working on tutorial for GPS positioning semi confused
0
adding AsyncTask to find location
-1
Android: How can I get the distance traveled while I'm running?



All Articles
Loading...
X
Show
Funny
Dev
Pics