The GetWayPoints and SubscribeWayPoints RPCs are designed to allow you to get the navigation destination(s) from the active navigation app if the user is navigating.
The GetWayPoints and SubscribeWayPoints RPCs are restricted by most vehicle manufacturers. As a result, the head unit you are connecting to will reject the request if you do not have the correct permissions. Please check the Understanding Permissions section for more information on how to check permissions for an RPC.
Since there is a possibility that some head units will not support getting the navigation destination, you should check head unit support before attempting to send the request. You should also update your app's UI based on whether or not you can use GetWayPoints.
You can use the SystemCapabilityManager to check the navigation capability returned by Core as shown in the code sample below.
sdlManager.getSystemCapabilityManager().getCapability(SystemCapabilityType.NAVIGATION, new OnSystemCapabilityListener() { @Override public void onCapabilityRetrieved(Object capability) { NavigationCapability navCapability = (NavigationCapability) capability; boolean isNavigationSupported = navCapability != null && navCapability.getWayPointsEnabled(); } @Override public void onError(String info) { HMICapabilities hmiCapabilities = (HMICapabilities) sdlManager.getSystemCapabilityManager().getCapability(SystemCapabilityType.HMI); boolean isNavigationSupported = hmiCapabilities.isNavigationAvailable(); } });
To subscribe to the waypoints, you will have to set up your callback for whenever the waypoints are updated, then send the SubscribeWayPoints RPC.
// Create this method to receive the subscription callback sdlManager.addOnRPCNotificationListener(FunctionID.ON_WAY_POINT_CHANGE, new OnRPCNotificationListener() { @Override public void onNotified(RPCNotification notification) { OnWayPointChange onWayPointChangeNotification = (OnWayPointChange) notification; //<#Use the waypoint data#> } }); // After SDL has started your connection, at whatever point you want to subscribe, send the subscribe RPC SubscribeWayPoints subscribeWayPoints = new SubscribeWayPoints(); subscribeWayPoints.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse rpcResponse) { if (rpcResponse.getSuccess()){ // You are now subscribed! } else { // Handle the errors } } @Override public void onError(int correlationId, Result resultCode, String info) { // Handle the errors } }); sdlManager.sendRPC(subscribeWayPoints);
To unsubscribe from waypoint data, you must send the UnsubscribeWayPoints RPC.
UnsubscribeWayPoints unsubscribeWayPoints = new UnsubscribeWayPoints(); unsubscribeWayPoints.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse rpcResponse) { if (rpcResponse.getSuccess()){ // You are now unsubscribed! } else { // Handle the errors } } @Override public void onError(int correlationId, Result resultCode, String info) { // Handle the errors } }); sdlManager.sendRPC(unsubscribeWayPoints);
If you only need waypoint data once without an ongoing subscription, you can use GetWayPoints instead of SubscribeWayPoints.
GetWayPoints getWayPoints = new GetWayPoints(); getWayPoints.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse rpcResponse) { if (rpcResponse.getSuccess()){ GetWayPointsResponse getWayPointsResponse = (GetWayPointsResponse) rpcResponse; <#Use the waypoint information#> } else { // Handle the errors } } @Override public void onError(int correlationId, Result resultCode, String info) { // Handle the errors } }); sdlManager.sendRPC(getWayPoints);