I'm trying to implement one of Mapbox's examples. They have an options builder implemented in the way shown below. But when I try to build it I get the error
error: Builder is abstract; cannot be instantiated
MapboxNavigationOptions options = new MapboxNavigationOptions.Builder().navigationNotification(customNotification).build();
I don't understand why this is exactly? Isn't this the way this class is supposed to be used?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
routeRefresh = new RouteRefresh(Mapbox.getAccessToken(), (RefreshCallback) getApplicationContext());
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
Context context = getApplicationContext();
CustomNavigationNotification customNotification = new CustomNavigationNotification(context);
MapboxNavigationOptions options = new MapboxNavigationOptions.Builder().navigationNotification(customNotification).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());
customNotification.register(new MyBroadcastReceiver(navigation), context);
}
I fixed this by removing the new
keyword and using MapboxNavigationOptions.builder()
instead of new MapboxNavigationOptions.Builder()
.