SmartEyeglass HeroSmartEyeglass Hero

Develop customized AR solutions

Sony’s augmented reality SmartEyeglass* is developed for increasing business productivity and reducing errors. Transform the way you work by enhancing reality with information and graphics.

*Discontinued model.

Companies interested in serial production of AR solutions, see SED-100A.


Your SmartEyeglass app can use dialogs to display text to users. The SmartEyeglassControlUtils class defines different types of dialogs that are convenient for informing your users of choices, events, or warnings.

The basics

To start working with dialogs, set up a project using the SampleDialogExtension; see more about creating SmartEyeglass projects in the How to create your first SmartEyeglass projecttutorial. In your class that extends ControlExtension, instantiate SmartEyeglassControlUtils and call methods in the Dialog API.

Dialog types

Choose a dialog type suitable for the app context in which you use it. You can choose one of the predefined types, or define your own custom type.

Dialog with timeout

Dialog with timeouts are useful for notifications that do not require user interaction or approval. This type of dialog only contains text and displays for five seconds. This behavior is modeled on Android Toasts.

Dialog with timeout.

This dialog closes on its own. When it closes, the onDialogClosed method returns a result code of -1 to your SmartEyeglassEventListener callback, indicating that the dialog was not closed by a button press.

OK dialog

Use this dialog when you need to get acknowledgements from the user. This type of dialog contains text and an “OK” button; it does not have a title line.

Dialog with OK button.

This dialog does not time out; the user must close it. When it closes, the onDialogClosed method returns a result code of 0 to your SmartEyeglassEventListener callback, indicating that the dialog was closed by the user pressing button 0 (the index of the single button).

Custom dialog

You can define a custom dialog to present choices to the user. This type of dialog contains a title, message text, and one to three buttons, whose labels you define.

You can also define multi-button dialogs to act as menus. For more information, see the code example below.

Dialog with a title, message, and three buttons.

A custom dialog does not time out; the user must close it by pressing one of the buttons. When it closes, the onDialogClosed method returns a result code to your SmartEyeglassEventListener callback, indicating which button the user pressed. The code is a 0-based index into the button array that you define.

How to display a dialog

To get started adding dialogs to your app, see the SampleDialogExtension in the SmartEyeglass SDK. This is the basic procedure.

  1. Create a class (such as SampleDialogControl) which extends the ControlExtension class of the SmartExtensionUtils library and instantiates a SmartEyeglassControlUtils member.
    1. class SampleDialogControl extends ControlExtension {
    2. private final SmartEyeglassControlUtils mSmartEyeglassControlUtils;
  2. Create a listener for the SmartEyeglass device, and define a handler for the onDialogClosed event, which returns the result when the dialog closes. For a dialog with several buttons, this handler will execute the chosen action.
    1. private final SmartEyeglassEventListener mSmartEyeglassEventListener =
    2. new SmartEyeglassEventListener() {
    3. @Override
    4. public void onDialogClosed(int code) {
    5. mDialogClosed = true;
    6. //Do something when the dialog closes.
    7. . . .
    9. }
    10. };
  3. In the constructor method, initialize the SmartEyeglassControlUtils member with your listener, than create the display elements and event handlers.
    1. SampleDialogControl (final String hostAppPackageName, final Context context) {
    2. super(context, hostAppPackageName);
    3. this.mSmartEyeglassControlUtils =
    4. new SmartEyeglassControlUtils (context, hostAppPackageName,
    5. mSmartEyeglassEventListener);
    6. // Create something
    7. . . .
    8. }
  4. To show a timeout or OK dialog, call the showDialogMessage() utility method:
    1. SmartEyeglassControlUtils.showDialogMessage(final String text, final int mode)

    The mode is an intent constant for the dialog type.

    • To show a text dialog with a 5-sec timeout, use SmartEyeglassControl.Intents.DIALOG_MODE_TIMEOUT.
    • To display a dialog with just the text and OK button, use SmartEyeglassControl.Intents.DIALOG_MODE_OK.

    These dialogs have the same text but different modes.

  5. To create and show a custom dialog, use this form of the showDialogMessage() utility method:
    1. SmartEyeglassControlUtils.showDialogMessage (final String title,
    2. final String message,
    3. final String[] buttons)

    A custom dialog with three buttons.

    The buttons parameter is a String array of button IDs. Your onDialogClosed handler receives a zero-based index into this array which indicates which button the user pressed to dismiss the dialog.

Learn from the code example

For the full code example of how to define and use dialogs, see the SampleDialogExtensionproject in the /samples folder of the SmartEyeglass SDK.