Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
JavaEE Guides
Popup Menus

Popup Menus

SDL supports modal menus. The user can respond to the list of menu options via touch, voice (if voice recognition is supported by the head unit), or by keyboard input to search or filter the menu.

There are several UX considerations to take into account when designing your menus. The main menu should not be updated often and should act as navigation for your app. Popup menus should be used to present a selection of options to your user.

Presenting a Popup Menu

Presenting a popup menu is similar to presenting a modal view to request input from your user. It is possible to chain together menus to drill down, however, it is recommended to do so judiciously. Requesting too much input from a driver while they are driving is distracting and may result in your app being rejected by OEMs.

Layout Mode Formatting Description
Present as Icon A grid of buttons with images
Present Searchable as Icon A grid of buttons with images along with a search field in the HMI
Present as List A vertical list of text
Present Searchable as List A vertical list of text with a search field in the HMI

Creating Cells

A ChoiceCell is similar to a RecyclerView without the ability to configure your own UI. We provide several properties on the ChoiceCell to set your data, but the layout itself is determined by the manufacturer of the head unit.

Note

On many systems, including VR commands will be exponentially slower than not including them. However, including them is necessary for a user to be able to respond to your prompt with their voice.

ChoiceCell cell = new ChoiceCell("cell1 text", Collections.singletonList("cell1"), null);
ChoiceCell fullCell = new ChoiceCell("cell2 text", "cell2 secondaryText", "cell2 tertiaryText", Collections.singletonList("cell2"), image1Artwork, image2Artwork);

Preloading Cells

If you know the content you will show in the popup menu long before the menu is shown to the user, you can "preload" those cells in order to speed up the popup menu presentation at a later time. Once you preload a cell, you can reuse it in multiple popup menus without having to send the cell content to Core again.

sdlManager.getScreenManager().preloadChoices(Arrays.asList(cell, fullCell), new CompletionListener() {
    @Override
    public void onComplete(boolean b) {
        // code
    }
});

Presenting a Menu

To show a popup menu to the user, you must present the menu. If some or all of the cells in the menu have not yet been preloaded, calling the present API will preload the cells and then present the menu once all the cells have been uploaded. Calling present without preloading the cells can take longer than if the cells were preloaded earlier in the app's lifecycle especially if your cell has voice commands. Subsequent menu presentations using the same cells will be faster because the library will reuse those cells (unless you have deleted them).

SYNC® 3 - List Only Interaction Layout

SYNC® 3 - Icon Only Interaction Layout

Note

When you preload a cell, you do not need to maintain a reference to it. If you reuse a cell with the same properties that has already been preloaded (or previously presented), the cell will automatically be reused.

Creating a Choice Set

In order to present a menu, you must bundle together a bunch of ChoiceCells into an ChoiceSet.

Note

If the ChoiceSet contains an invalid set of ChoiceCells, presenting the ChoiceSet will fail. This can happen, for example, if you have duplicate title text or if some, but not all choices have voice commands.

Some notes on various parameters (full documentation is available as API documentation on this website):

  • Title: This is the title of the menu when presented

  • Listeners: You must implement this listener interface to receive callbacks based on the user's interaction with the menu

  • Layout: You may present your menu as a set of tiles (like a GridView) or a list (like a RecyclerView). If you are using tiles, it's recommended to use artworks on each item.

ChoiceSet choiceSet = new ChoiceSet("ChoiceSet Title", Arrays.asList(cell, fullCell), new ChoiceSetSelectionListener() {
    @Override
    public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource, int rowIndex) {
        // You will be passed the `cell` that was selected, the manner in which it was selected (voice or text), and the index of the cell that was passed.      
        // handle selection
    }

    @Override
    public void onError(String error) {
        // handle error            
    }
});

Presenting the Menu with a Mode

Finally, you will present the menu. When you do so, you must choose a mode to present it in. If you have no vrCommands on the choice cell you should choose manualOnly. If vrCommands are available, you may choose voiceRecognitionOnly or both.

You may want to choose this based on the trigger source leading to the menu being presented. For example, if the menu was presented via the user touching the screen, you may want to use a mode of manualOnly or both, but if the menu was presented via the user speaking a voice command, you may want to use a mode of voiceRecognitionOnly or both.

It may seem that the answer is to always use both. However, remember that you must provide vrCommands on all cells to use both, which is exponentially slower than not providing vrCommands (this is especially relevant for large menus, but less important for smaller ones). Also, some head units may not provide a good user experience for both.

Interaction Mode Description
Manual only Interactions occur only through the display
VR only Interactions occur only through text-to-speech and voice recognition
Both Interactions can occur both manually or through VR

SYNC® 3 - Menu - Manual Only

SYNC® 3 - Menu - Voice Only

sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY);

Presenting a Searchable Menu

In addition to presenting a standard menu, you can also present a "searchable" menu, that is, a menu with a keyboard input box at the top. For more information on implementing the keyboard callbacks, see the Popup Keyboards guide.

SYNC® 3 - Menu with Search Interaction Layout

sdlManager.getScreenManager().presentSearchableChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY, keyboardListener);

Deleting Cells

You can discover cells that have been preloaded on sdlManager.getScreenManager().getPreloadedChoices(). You may then pass an array of cells to delete from the remote system. Many times this is not necessary, but if you have deleted artwork used by cells, for example, you should delete the cells as well.

sdlManager.getScreenManager().deleteChoices(<List of choices to delete>);

Dismissing the Popup Menu (RPC v6.0+)

You can dismiss a displayed choice set before the timeout has elapsed by sending a CancelInteraction request. If you presented the choice set using the screen manager, you can dismiss the choice set by calling cancel on the ChoiceCell object that you presented.

Note

If connected to older head units that do not support this feature, the cancel request will be ignored, and the choice set will persist on the screen until the timeout has elapsed or the user dismisses it by making a selection.

choiceSet.cancel();

Duplicate Cell Titles

Starting with SDL v5.1+ choice cells no longer require unique titles in order to be presented. For example, if you are trying to display points of interest as a list you can now have multiple locations with the same name but are not the same location. You cannot present multiple cells that are exactly the same. They must have some property that makes them different, such as secondaryText or an artwork.

RPC v7.1+ Connections

The titles on the choice set will be displayed as provided even if there are duplicate titles.
Choice Set with duplicate names RPC 7.1+

RPC v7.0 And Below Connections

The titles on the choice set will have a number appended to them when there are duplicate titles.
Choice Set with duplicate names

Using RPCs

If you don't want to use the ScreenManager, you can do this manually using the Choice, CreateInteractionChoiceSet, and PerformInteraction. You will need to create Choices, bundle them into CreateInteractionChoiceSets. As this is no longer a recommended course of action, we will leave it to you to figure out how to manually do it.

Note that if you do manually create a PerformInteraction and want to set a cancel id, the ScreenManager takes cancel ids 0 - 10000. Any cancel id you set must be outside of that range.

View on GitHub.com
Previous Section Next Section