The SmartEyeglass is one of a family of Sony accessories that are operated by software running on an Android device that is paired with the accessory device over a Bluetooth or Wireless LAN connection.
The software architecture is based on set of applications that run on the host Android device (a smartphone).
- SmartConnect is a component that must be installed on the host Android device. This component keeps track of what accessory devices are available, and which apps support which devices. SmartConnect comes pre-installed on most Xperia devices. You should update to the latest version, which can be downloaded for free from Google Play.
(For Android versions earlier than Android 4.0, this framework was called LiveWare™ Manager. You might still see this term in API and file names.)
- A Host Application handles communication between the host Android device and the accessory device, over a Bluetooth or Wireless LAN connection. The HostApp instance for SmartEyeglass can be downloaded for free from Google Play.
- Your application uses the SmartExtension API framework along with accessory-specific APIs to work with a specific accessory device. For example, you might extend the
ControlExtensionclass defined in the
SmartEyeglassAPIlibrary in order to control the camera that is built into SmartEyeglass. Your apps actually run on the host phone and communicate to the accessory via Bluetooth or Wireless LAN.
The host application runs on the host device, and handles all interaction with a specific accessory. There is one host application for each accessory. The host application uses ContentProviders in Smart Connect to find information about which apps should be available on the accessory.
In order to test your SmartEyeglass app, you must install the HostApp instance and SmartConnect on your host Android device. See the Get started page.
Notice that each accessory has its own HostApp instance. Your app can communicate with multiple host apps. For example, if you already have an existing SmartWatch2 app, you can extend it to support a SmartEyeglass interface as well; see the tutorial How to add SmartEyeglass support to your SmartWatch2 app for more information.
Get access to the API libraries
The libraries that you include in your SmartEyeglass app provide a framework of basic services, while the sample projects provide examples of device-specific functionality. For programmatic access to the SmartEyeglass device, you must include these library projects in your application:
- SmartExtensionsAPI and SmartExtensionsUtils: These libraries provide a framework of basic services; the Android Intents that can be sent and received by any Sony accessory device, and the utility classes that are used or extended to work with the system infrastructure.
- SmartEyeglassAPI: This library defines the utility classes that you extend to provide your application logic and functionality, the events that you use to define your app’s behavior, and constants that you use to configure your app and the device.
Note that you must include the source code for these libraries, not the compiled JAR files.
In addition, you should include one or more of the sample projects. These provide examples of common use cases, such as how to draw a Layout to the display, or receive and display Notifications. You can use them as templates for your own projects.
Together, these projects define the all of the API elements that you use to access and control the device, as well as constants and utility methods that must be included in any SmartEyeglass app. For complete details of the classes and methods in these libraries, see the API references documentation.
Anatomy of a SmartEyeglass project
The sample projects include most or all of these extensions to utility classes that are defined in the SmartEyeglass or SmartExtension libraries. Each sample has a version that is customized for particular functionality, which you can modify as needed.
These classes are common to most SmartExtension app projects:
Registers your app with the correct instance of HostApp and sets up the configuration. The instance in a particular sample registers the correct version of any API being used in that sample, as well as app-specific details such as the associated display name and icon. See the Registration and capabilities guide for more information.
Starts the ExtensionService, which executes your SmartEyeglass app when the user selects your widget-level card in the main menu.
Creates a ControlExtension instance that supports the display size of the current accessory device (in this case the SmartEyeglass).
Sets up a preference activity for your app that runs on the phone, and can be accessed through SmartConnect. Not all samples need this. You can use it to show a read-me or configuration information for your app.
Access specific functionality
Most apps extend the
ControlExtension class in order to define the UI and behavior of the application. This is typically where you define the main logic for your application, such as event callbacks and listeners and screen updates. Many sample apps define a class
Sample[xx]Control. (Some apps, such as those that display notifications, don’t need to extend the
SmartEyeglassUtils package contains these important classes:
- SmartEyeglassControlUtils: Your class that extends
SmartEyeglassControlUtilsin order to use the utility methods for SmartEyeglass-specific functionality. Utilities include APIs for camera, voice input, display tools such as dialogs and layer transition effects, and configuration options such as power modes and sound effects.
- SmartEyeglassEventListener: Instantiate this class in order to listen for and respond to device-specific events, such as receiving the results of camera activation.
Other functionality is defined at the level of the
SmartExtensionUtils library. This library defines these these important classes, in addition to
- NotificationUtil: Provides the notification API. For more information, see the Notifications guide.
- AccessorySensorManager: Provides the API for detecting sensors and accessing sensor data. For more information, see the Sensor data guide.
- WidgetExtension: Provides the API for defining display widgets. For more information, see the Widgets guide.
- RegistrationInformation: See the Registration and capabilities guide.
When you create your own application project, look at the sample code to see how it implements basic functionality, and extend the existing classes or create new classes to add your own UI and behavior.
Update your Android manifest
A SmartEyeglass app is an Android app, so it requires an Android manifest just as any standard Android app does. Every sample project includes a manifest, which you should modify to suit your own app. In addition to the typical things you might define in your Android manifest, you must declare the following permissions in order to get access to the SmartEyeglass APIs:
- SmartEyeglass Camera API:
<uses-permission android:name=”com.sony.smarteyeglass.permission.CAMERA” />
- SmartEyeglass Voice Text Input API:
<uses-permission android:name=”com.sony.smarteyeglass.permission.VOICE_TEXT_INPUT” />
- Framework and all other SmartEyeglass APIs:
<uses-permission android:name=”com.sonyericsson.extras.liveware.aef.EXTENSION_PERMISSION” /> <uses-permission android:name=”com.sony.smarteyeglass.permission.SMARTEYEGLASS” />