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.


This page explains how to receive a notification on the SmartEyeglass. Notifications in the SmartExtensions framework are similar to standard Android Notifications. You can use them to notify users when they receive, for example, an SMS, email, or Facebook update.

The SmartExtensions framework provides a notifications service based on Android ContentProviders. Your application can use the service to inform users of new events or messages using the SmartEyeglass display.

The basics

To get started configuring notifications for SmartEyeglass display, set up a project using the HelloNotification sample; see more about creating SmartEyeglass projects in the How to create your first SmartEyeglass project tutorial.

The notification functionality is implemented at the level of the SmartExtensions API. As for any SmartEyeglass project, you must include the SmartExtensions libraries in your project. You must also update your AndroidManifest.xml file with Intent filters for the Notification API, as defined by the NotificationUtil class in the SmartExtensionUtils library. The manifest in the sample does this. See SmartEyeglass API overview for more details on updating your Android Manifest.

These classes in the HelloNotification sample project implement the SmartEyeglass handling of notifications: HelloNotificationRegistrationInformation HelloNotificationExtensionService HelloNotificationPreferenceActivity

Design a safe notification display

You can extend the ExtensionService class, as shown in the sample, to specify what information is displayed in the notification. For SmartEyeglass applications, the user status (moving or still) and screen status (on or off) will determine how notifications are displayed.

The sudden display of text tends to distract the user, especially when the screen is off. Whenever the user is in motion, it is recommended that you avoid displaying text on the SmartEyeglass; as in this case, an icon should be sufficient. When the user is still, it is safe to provide more details.

When screen is off, display style depends on user’s motion.

When the screen is off and the user is in motion, a notification shows only the 52×52 pixel application icon for the sending application. When the user is at rest, the user name is added to the display.

When screen is on, the display includes message information.

When the screen is on, information about the sending application is displayed along with additional message details, including a 52×52 pixel icon and 24-pixel text.

In all cases, the notification flashes three times in two seconds, and then remains on the screen for one second. To make sure users know which application sent the notification, we recommend that you use a clear, recognizable icon.

Configure notifications

To support notifications in your SmartEyeglass app, you must identify notification sources that you are interested in, and define which notification information you want to display in particular circumstances.

Add a notification source

A notification source is a ContentValues object in your extension’s registration information that identifies where notifications are coming from. To receive notifications, you must add at least one source. It is possible to have notifications come from multiple sources, such as from multiple RSS feeds. If you plan to support multiple sources, you will need to create a ContentValue list of different source configurations and return all of them as an array. For example:

  1. @Override
  2. public ContentValues[] getSourceRegistrationConfigurations() {
  3. List bulkValues = new ArrayList();
  4. bulkValues.add(getSourceRegistrationConfiguration (SampleExtensionService.EXTENSION_SPECIFIC_ID));
  5. return bulkValues.toArray(new ContentValues[bulkValues.size()]);
  6. }

Configure each notification source

When you have registered your extension to support the Notification API, the host app will call getSourceRegistrationConfiguration()for your extension in order to get the specific configuration information for notification source. You will need to override this method to define the configuration values you want for your notification source such as icon, source name, whether it supports text to speech, and so on. For more information about which values are supported, see the Notification.SourceColumns constants in the API references.

This is the configuration method defined for the sample:

  1. /**
  2. * Get source configuration for this extension
  3. * @param Your extension’s unique ID
  4. * @return The source configuration
  5. */
  6. public ContentValues getSourceRegistrationConfiguration (String extensionSpecificId) {
  7. ContentValues sourceValues = null;
  9. String iconSource1 = ExtensionUtils.getUriString(mContext, R.drawable.icn_30x30_message_notification);
  10. String textToSpeech = mContext.getString(R.string.text_to_speech);
  11. sourceValues = new ContentValues();
  13. sourceValues.put(Notification.SourceColumns.ENABLED, true);
  14. sourceValues.put(Notification.SourceColumns.ICON_URI_1, iconSource1);
  15. sourceValues.put(Notification.SourceColumns.UPDATE_TIME, System.currentTimeMillis());
  16. sourceValues.put(Notification.SourceColumns.NAME, mContext.getString(R.string.source_name));
  17. sourceValues.put(Notification.SourceColumns.EXTENSION_SPECIFIC_ID, extensionSpecificId);
  18. sourceValues.put(Notification.SourceColumns.PACKAGE_NAME, mContext.getPackageName());
  19. sourceValues.put(Notification.SourceColumns.TEXT_TO_SPEECH, textToSpeech);
  21. // Menu actions and icons
  22. sourceValues.put(Notification.SourceColumns.ACTION_1, mContext.getString(R.string.action_event_1));
  23. sourceValues.put(Notification.SourceColumns.ACTION_2, mContext.getString(R.string.action_event_2));
  24. sourceValues.put(Notification.SourceColumns.ACTION_3, mContext.getString(R.string.action_event_3));
  25. sourceValues.put(Notification.SourceColumns.ACTION_ICON_1, ExtensionUtils.getUriString(mContext, R.drawable.actions_1));
  26. sourceValues.put(Notification.SourceColumns.ACTION_ICON_2, ExtensionUtils.getUriString(mContext, R.drawable.actions_2));
  27. sourceValues.put(Notification.SourceColumns.ACTION_ICON_3, ExtensionUtils.getUriString(mContext, R.drawable.actions_3));
  29. return sourceValues;
  30. }

Display a notification

To display the notification, add it to the notification database by inserting it into the notification ContentResolver. When it receives a notification that is in the database, the host application pushes it out to the accessory to be displayed.

When you add a notification, you can specify the title (DISPLAY_NAME) and message (MESSAGE). These values are added to a ContentValues object and inserted into the database. Values for PERSONALPUBLISHED_TIME, and SOURCE_ID are also required. For details on the values supported see the API references for Notification.EventColumns.

  1. String name = “Earth”;
  2. String message = “Hello World!”;
  3. long time = System.currentTimeMillis();
  4. long sourceId = NotificationUtil.getSourceId(this, EXTENSION_SPECIFIC_ID);
  5. . . .
  6. ContentValues eventValues = new ContentValues();
  7. eventValues.put(Notification.EventColumns.DISPLAY_NAME, name);
  8. eventValues.put(Notification.EventColumns.MESSAGE, message);
  9. eventValues.put(Notification.EventColumns.PERSONAL, 1);
  10. eventValues.put(Notification.EventColumns.PUBLISHED_TIME, time);
  11. eventValues.put(Notification.EventColumns.SOURCE_ID, sourceId);
  12. . . .
  13. getContentResolver().insert(Notification.Event.URI, eventValues);
  14. . . .

Add an image to your notification

Typically, a notification displays the sending user’s profile image. If you want to do this, add a PROFILE_IMAGE_URI as one of your content values. For example:

  1. String profileImage = ExtensionUtils.getUriString(this, R.drawable.widget_default_userpic_bg);
  2. ...
  3. eventValues.put(Notification.EventColumns.PROFILE_IMAGE_URI, profileImage);
  4. ...

Handle menu actions

You can define a menu to be shown in the notification view when the user drills down into the notification details.

Menu for notification view, defined by HelloNotification sample code.

To do this, override the onViewEvent() method and add your action handling code:

  1. @Override
  2. protected void onViewEvent(Intent intent) {
  3. String action = intent.getStringExtra(Notification.Intents.EXTRA_ACTION);
  4. . . .
  5. if (Notification.SourceColumns.ACTION_1.equals(action)) {
  6. Toast.makeText(this, "Action 1", Toast.LENGTH_LONG).show();
  7. }
  8. else if (Notification.SourceColumns.ACTION_2.equals(action)) {
  9. Toast.makeText(this, "Action 2", Toast.LENGTH_LONG).show();
  10. }
  11. else if (Notification.SourceColumns.ACTION_3.equals(action)) {
  12. Toast.makeText(this, "Action 3", Toast.LENGTH_LONG).show();
  13. }
  14. }

Learn from the code example

For the full code example showing how to use notifications, see the HelloNotification sample project in the /samples folder of the SmartEyeglass SDK.