Search in sources :

Example 1 with NavigationNotification

use of com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification in project mapbox-navigation-android by mapbox.

the class NavigationService method initializeNotification.

/**
 * Builds a new navigation notification instance (either custom or our default implementation)
 * and attaches it to this service.
 */
private void initializeNotification(MapboxNavigationOptions options) {
    if (options.navigationNotification() != null) {
        navigationNotification = options.navigationNotification();
        Notification notification = navigationNotification.getNotification();
        int notificationId = navigationNotification.getNotificationId();
        startForegroundNotification(notification, notificationId);
    } else {
        navigationNotification = new MapboxNavigationNotification(this, mapboxNavigation);
        Notification notification = navigationNotification.getNotification();
        int notificationId = navigationNotification.getNotificationId();
        startForegroundNotification(notification, notificationId);
    }
}
Also used : NavigationNotification(com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification) Notification(android.app.Notification)

Example 2 with NavigationNotification

use of com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification in project mapbox-navigation-android by mapbox.

the class MockNavigationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mock_navigation);
    ButterKnife.bind(this);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    // Use a custom notification
    CustomNavigationNotification customNavigationNotification = new CustomNavigationNotification(this);
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().navigationNotification(customNavigationNotification).build();
    navigation = new MapboxNavigation(this, Mapbox.getAccessToken(), options);
    navigation.addMilestone(new RouteMilestone.Builder().setIdentifier(BEGIN_ROUTE_MILESTONE).setInstruction(new BeginRouteInstruction()).setTrigger(Trigger.all(Trigger.lt(TriggerProperty.STEP_INDEX, 3), Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 200), Trigger.gte(TriggerProperty.STEP_DISTANCE_TRAVELED_METERS, 75))).build());
}
Also used : CustomNavigationNotification(com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification) MapboxNavigationOptions(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) RouteMilestone(com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)

Aggregations

Notification (android.app.Notification)1 CustomNavigationNotification (com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification)1 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)1 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1