Mapbox-navigation-android: Version 0.4.0 calls onProgressChange(), while version 0.5.0 and 0.6.0-SNAPSHOT fails on that.

Created on 7 Sep 2017  路  16Comments  路  Source: mapbox/mapbox-navigation-android

I've implemented version 0.4.0 and MapboxNavigation successfully fires onProgressChange() when user's location changes. But version 0.5.0 and 0.6.0-SNAPSHOT won't trigger onProgressChange(), even though the user moves with speed over 0(zero).

All 16 comments

Yes it is true. I've written about it in this comment https://github.com/mapbox/mapbox-navigation-android/issues/213#issuecomment-328271145

@mecoFarid Can you debug the same question I asked @samvgorode in https://github.com/mapbox/mapbox-navigation-android/issues/213#issuecomment-329783383

Should be resolved in https://github.com/mapbox/mapbox-navigation-android/pull/236 which fixes an issue with routeProgress not getting updated after a reroute.

Still doesn't work on 0.6.0

@kirtan-inexture, could you give us some more insight on your setup so we can reproduce the issue?

Same, as on previous version. Didn't work with 0.5.0 also. It gives an initial callback. But after that it doesn't update at all.

    MapboxNavigationOptions options = MapboxNavigationOptions.builder()
            .maximumDistanceOffRoute(10).build();
    navigation = new MapboxNavigation(this, Mapbox.getAccessToken(), options);

   // requesting a route
   final NavigationRoute navigationRoute = NavigationRoute.builder()
            .accessToken(getString(R.string.mapbox_access_token))
            .origin(origin)
            .destination(destination)
            .build();

    navigationRoute.getRoute(new Callback<DirectionsResponse>() {
        @Override
        public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
                mapboxMap.setMyLocationEnabled(true);
                navigation.addMilestoneEventListener(HomeScreen.this);
                navigation.addNavigationEventListener(HomeScreen.this);
                navigation.addOffRouteListener(HomeScreen.this);
                navigation.addProgressChangeListener(HomeScreen.this);

                navigation.setLocationEngine(new AndroidLocationEngine(HomeScreen.this));

                mRoute = response.body().getRoutes().get(0);
                navigation.startNavigation(mRoute);
             }
        });

It gives onProgress callback for 1 single time only. But never updates.

hi @cammace , could you please take a look at this for us as @kirtan-inexture has posted.
We have also emailed mapbox support along with you. Trying to get this sorted asap so any help is appreciated. Thanks in advance! Joe

@onsceneio, can you try removing the setLocationEngine line and allowing the default location engine to setup. Otherwise, make sure the AndroidLocationEngine you are using gets activated and uses a similar setup to what we do for the default one.

https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxNavigation.java#L158

@cammace Tried both way. Nothing worked. onRunning() called for only 1 time only.

Can you just reopen the issue so that others can also find this and report it.

@kirtan-inexture Can you try the location engine setup we use in our NavigationView? The LocationEngine needs to be activated.

https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L451

The class that activates the LocationEngine needs to also implement LocationEngineListener.

Once activate() is called, https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L216
will be called and you can start requesting location updates.

Please note at this point, if you haven't requested location permissions from the user, the app will throw an exception.

Once the LocationEngine is activated and requesting location updates, you can pass it to MapboxNavigation and begin navigation:
https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L605

@danesfeder I think I don't need to setup a location engine because it uses the default one if I don't provide.

If I provide a location engine, as suggested by @cammace , that also didn't worked. The below code also didn't worked:

            AndroidLocationEngine locationEngine = new AndroidLocationEngine(HomeScreen.this);
            locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
            locationEngine.setFastestInterval(1000);
            locationEngine.setInterval(0);
            locationEngine.activate();
            navigation.setLocationEngine(locationEngine);

If remove those lines also, with default location engine, the navigation callback only called single time.

I migrated code from 0.3.2 and it worked there. But from 0.5.0 it is not working at all.

Something is broken from your side, I guess.

@kirtan-inexture In the code above, you are not setting a LocationEngineListener

https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L454

You need to do this so you can request location updates when you call locationEngine.activate()

https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L216

The location engine fires once and then never again because we force a first update with the last known location here

https://github.com/mapbox/mapbox-navigation-android/blob/master/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java#L145

But, because you never call locationEngine.requestLocationUpdates() prior to setting the LocationEngine, MapboxNavigation never sees any more updates.

Hi, @danesfeder
The thing that simply worked was calling locationEngine.requestLocationUpdates(). But now the issue is, after 5 mins of usage it becomes unresponsive. Continues GC was called by art and 5 min after, app isn't responding at all. Crashed/Restarted Android System UI twice.

Also, requestLocationUpdates() method continues to request location even if I stops the navigation with endNavigation()

I remember, with previous version 0.3.X, I didn't have to setup the location engine. It worked without setting up all these things. May be a detailed documentation would be very helpful. Also from 0.3.X so many things have changed including package names and listeners itself.

Any progress on this?

@danesfeder Any updates?

I have just logged onProgressChange method with 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.7.0-SNAPSHOT'
So, I start navigation, I don't move at all, but get such result

10-03 16:17:05.356 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:06.444 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:07.064 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:07.954 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:08.947 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:09.953 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:10.931 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:11.942 25430-25430/? E/Progress: 22.27268 22.27268
10-03 16:17:12.943 25430-25430/? E/Progress: 22.27268 22.27268

The same coordinates from onProgressChange location 9 times at onse. It's strange
And I use locationEngine = LostLocationEngine.getLocationEngine(context);

Was this page helpful?
0 / 5 - 0 ratings