Forward compatible development
- To develop an app that works on both SmartWatches, use the older version of the Smart Extension APIs (version 1.0), or have the app support version 1.0 and version 2.0 and newer versions of the Smart Extension APIs.
The following section describes how to implement forward compatibility if you have already developed apps for the original SmartWatch.
There are essentially two different ways to develop an app that will work on both the original SmartWatch and SmartWatch 2:
- Only use the older version of the Smart Extension APIs (version 1.0).
- Have the app support both the older (version 1.0) and newer version of the Smart Extension APIs (version 2.0 and newer).
Use only Smart Extension APIs – version 1.0
Since the SmartWatch 2 is, to a large extent, backwards compatible with the original SmartWatch, it may be most convenient to just use the older version of the Smart Extension APIs. The downside of this approach is that the user experience of the app might not be as good as it could have been if the new version of the Smart Extension APIs were used. Nonetheless, it is an option and this section will address some of the things to consider when using this approach, namely widgets, screen size and icon size.
Widgets using only Widget API version 1.0 can’t be used in SmartWatch 2 currently. In order to create an app supporting both the original SmartWatch and SmartWatch 2, the implementation has to include both version 1.0 and version 3.0 Widget support. See the BackwardsCompatibleWidget sample included in the Sony Add-on SDK for an example of how to do this.
The screen of SmartWatch 2 has a resolution of 220 x 176 pixels and the entire screen is available to an app that uses the Control API. Apps written for the original SmartWatch’s resolution of 128 x 128 pixels will be automatically scaled to fit the SmartWatch 2, while keeping the aspect ratio. Touch coordinates will be converted as well, so the app can still react, to touch events for example, using the same code it did for the original SmartWatch without any changes.
Test your original SmartWatch app on the SmartWatch 2 to ensure the scaling is not causing any unwanted graphical artifacts or distortions. Should this be the case, or if you want to take advantage of the full resolution of the display, or provide crisper graphics, an app that draws using Control API version 1.0 can still choose to draw its control for the resolution of 220 x 176. In this case, to keep backwards compatibility, the app would need to be able to draw for both 128 x 128 and 220 x 176 pixels and choose the appropriate resolution based on the display size of the SmartWatch it has connected to. An app can query the display size of the device using the Registration and Capabilities API.
The app icon used in the home screen of SmartWatch 2 is 48 x 48 pixels, compared to the original SmartWatch icon size of 36 x 36 pixels. When registering, the app can provide this icon using the new constant defined by ExtensionColumns.EXTENSION_48PX_ICON_URI. If an app does not provide this icon but provides a 36 x 36 icon using ExtensionColumns.EXTENSION_ICON_URI, SmartWatch 2 will use this icon on the home screen instead. It is recommended that extensions are updated to provide a 48 x 48 pixel icon for SmartWatch 2.
Note that the ExtensionColumns.EXTENSION_48PX_ICON_URI column does not exist in some older versions of the SmartConnect application. To avoid your app failing to register on devices running on of these older versions, you can use the convenience registration methods in the utility library in the latest version of the Sony Add-on SDK. For example, the SampleControlExtension uses these.
Use version 1.0 Smart Extension APIs with version 2.0 or newer of the Smart Extension APIs
To take full advantage of SmartWatch 2, an app should consider using the newer version of the Smart Extension APIs (version 2.0 and later). Since the original SmartWatch does not support this version of the API, an app needing to keep backwards compatibility while still being able to use the newer version of the Smart Extension APIs, could split its usage of the API versions in separate components and switch between these depending on whether or not it’s connected to a device that supports the new Smart Extension APIs.
The RegistrationInformation class in the utility libraries provided with the Sony Add-on SDK has new methods for an app to specify support for both API versions. The newer methods, when overridden by the app, allow setting a target API version and in absence of the target API version, and state which version of the API the app requires. Refer to the sample control app, BackwardsCompatibleControl, provided with the Sony Add-on SDK for an example of how to implement these features.
Notification API – version 2.0 and later
The newer version of the Notification API (version 2.0 and later) allows use of icons instead of text for the action menu. Note that SmartWatch 2 currently does not support having some menu items as labels and some as icons within the same menu.
An app can also associate a color with its notification. SmartWatch 2 currently uses this to set the color of the status bar when showing the app’s list of event or a full screen view of a particular event belonging to the app. Refer to the sample control app, HelloNotification, provided with the Sony Add-on SDK for an example of how to implement these features.
Layouts instead of bitmaps
The newer version of the Control API (version 2.0 and later) adds the possibility to render the display using a subset of Android’s layouts as opposed to just using bitmaps. This allows an app to, for example, generate a full screen display that requires less data to be sent to the SmartWatch through Bluetooth, thereby increasing its performance. By using the Android views ListView or Gallery, smoother scrolling can also be achieved when using the Control API. Refer to the control app code example, AdvancedLayouts, provided with the Sony Add-on SDK for an example of how to implement these features.
An app that wants to send its data to the host application using layouts instead of bitmaps need to register itself as using the new version of the Control API.
To draw using a layout instead of a bitmap, instead of using Control.Intents.CONTROL_DISPLAY_DATA_INTENT and providing bitmap data, use Control.Intents.CONTROL_PROCESS_LAYOUT_INTENT.
When drawing using layouts, some views can report touch events, alleviating the need for the app to calculate what was clicked, based on touch coordinates. To enable this, set the attribute android:clickable on the view. These touch events are sent to the app using the intent Control.Intents.CONTROL_OBJECT_CLICK_EVENT_INTENT or Control.Intents.CONTROL_LIST_ITEM_CLICK_INTENT. Refer to the control apps code example, HelloLayouts and AdvancedLayouts, provided with the Sony Add-on SDK for an example of how to implement these features.