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.


Widgets are visual components that can provide run-time information such as weather or number of unread emails.

In the SmartEyeglass UI architecture, a widget is used as the entry point to your app. The SmartEyeglass SDK allows you to customize the card that represents your app in the main menu, using the WidgetExtension API.

The basics

To start designing you own entry-point card, set up a project using the HelloWidget sample as a base. See more about creating SmartEyeglass projects in the How to create your first SmartEyeglass project tutorial.

You will use the Widget API to create your widget, so the class that extends RegistrationInformation must get the version that supports this functionality:

  1. @Override
  2. public int getRequiredWidgetApiVersion() {
  3. return 3;
  4. }

The HelloWidget project does this. If you don’t use this sample as a base, make sure you do the same.

Define a widget

Extend the WidgetExtension class in order to create your own type of widget.

When a widget is shown on the SmartEyeglass display, the Extension service in the SmartExtension framework calls the onStartRefresh() method. In your class that extends WidgetExtension, override this method to update the screen content to be displayed when the widget is visible.

Your widget can show a bitmap or a custom layout. See the User interface guide for details of how to define screen displays. For example, this simple widget displays a custom layout when it is shown:

  1. class HelloWidget extends WidgetExtension {
  3. // Create a widget extension.
  4. public HelloWidget(Context context, String hostAppPackageName) {
  5. super(context, hostAppPackageName);
  6. }
  8. @Override
  9. public void onStartRefresh() {
  10. // Send a UI layout when the widget is visible.
  11. showLayout(R.layout.layout_widget);
  12. }
  13. }

When a widget is no longer visible, the framework calls the onStopRefresh() callback.

Register your widget

If you define widgets, you must register this fact with the SmartExtension framework. In your class that extends RegistrationInformation, add code to indicate that your extension supports widgets of the size required for the SmartEyeglass display:

  1. @Override
  2. public boolean isWidgetSizeSupported(final int width, final int height) {
  3. return (height == SmartEyeglassWidgetImage.getSupportedWidgetHeight(mContext) &&
  4. width == SmartEyeglassWidgetImage.getSupportedWidgetWidth(mContext));
  5. }

Create your widget

The Extension service in the SmartExtensions framework calls createWidgetExtension() to get a widget to display for your entry card in the main menu. In your class that extends ExtensionService, override this method to create and return an instance of the widget you have defined:

  1. @Override
  2. public WidgetExtension createWidgetExtension(String hostAppPackageName) {
  3. return new HelloWidget(this, hostAppPackageName);
  4. }

Learn from the code example

For the full code example showing how to create a widget that can be placed in the SmartEyeglass main menu, see the HelloWidget project in the SmartEyeglass SDK.