[SmartEyeglass General] Geeks Empire:
Programming for Wearable Products of Sony (SmartEye-Glass)

The newest wearable project of Sony is the SmartEye-Glass. As we know Sony was one of the first company that seriously worked on smart wearable tech, actually Smart-Watch word is for Sony from the first generation of Smart-Watch.

Because There is lots of & Tutorial for SmartWatch I decided to start with SmartEye-Glass. However this is still preview of this SDK & I will update this tutorial as soon as final sdk release.

### Let Start ###

1. Install SmartEyeGlass SDK (Preview)

* Android SDK Manager:

- Open SDK-Manager go to > Tools > Manager Add-on Sites > User Defined (tab) > New > Add this URL

http://dl.developer.sony.com/wearables/sdks/Sony-SmartEyeglass-SDK.xml

- Close & Relaunch the SDK-Manager

- In API-18 section you should have Sony

SmartEyeGlass SDK Developer Preview

- Select & Install

* Manually:

- I attached the Compiled Library of SmartEyeGlass.

Download, unzip & Import to your WorkSpace

- To Develop Or Compile Sample code you should Add this library to your project

Right Click on Project > Properties > Android > in Library section > Add & Select All three package.[/CODE

[CENTER]***
[B]Ready To Coding for SmartEyeGlass[/B]

[B]^-^-^[/B]
[LEFT][SIZE=5][COLOR=DimGray]2. [B]Starting...
[/B][/COLOR][/SIZE]As Sony recommends, It s better to [B]Import Samples & Modify [/B]It. But will explain little bit about each part.
[FONT=Century Gothic][SIZE=4][FONT=Comic Sans MS]
#First For those who just want to test[/FONT][/SIZE][/FONT][B][FONT=Century Gothic][SIZE=4]
[/SIZE][/FONT][/B][FONT=Century Gothic][SIZE=3][FONT=Comic Sans MS]1. Download & Install [URL="http://xdaforums.com/attachment.php?attachmentid=2957949&stc=1&d=1412279989"][COLOR=DeepSkyBlue][B]SmartEyeglassEmulator.apk[/B][/COLOR][/URL] + [/FONT][/SIZE][/FONT][FONT=Century Gothic][SIZE=3][FONT=Comic Sans MS][URL="http://xdaforums.com/attachment.php?attachmentid=2957948&stc=1&d=1412279989"][COLOR=DeepSkyBlue][B][FONT=Century Gothic][FONT=Comic Sans MS]SmartEyeglass.apk[/FONT][/FONT][/B][/COLOR][/URL]
2. Then Install One of the Application from [URL="http://xdaforums.com/attachment.php?attachmentid=2957870&stc=1&d=1412275816"][COLOR=DeepSkyBlue][B]samplesAPK.rar [/B][/COLOR][/URL]
3. Now Open the [/FONT][/SIZE][/FONT][FONT=Century Gothic][SIZE=3][FONT=Comic Sans MS][FONT=Century Gothic][FONT=Comic Sans MS][B]SmartEyeglassEmulator[/B][/FONT][/FONT] app
4. [B]Swipe Left/Right[/B] on [COLOR=SeaGreen][B]green[/B] [/COLOR]area to find Installed App & Click on [B]Touch Sensor[/B] button to Select.
5. For Example, Select Sample Voice Text Input + Turn ON [B]PTT [/B]switch & Speak [SIZE=2](Internet Connection Required)[/SIZE]
6. That s it... Just Install other App & play with them ;)
check out the SceenShot;[/FONT][/SIZE][/FONT][B][FONT=Century Gothic][SIZE=4]
[/SIZE][/FONT][/B][CENTER][HIDE][IMG]http://xdaforums.com/attachment.php?attachmentid=2957871&stc=1&d=1412275818[/IMG][/HIDE]

[/CENTER]
[B][FONT=Century Gothic][SIZE=4]
# SampleVoiceTextInput [/SIZE][/FONT][/B][FONT=Lucida Console][SIZE=2]Codes Descriptions[/SIZE][/FONT][B]
I.[/B] First you should add required [B]permissions[/B] in [B]Manifest.xml[/B].
[CODE] <uses-permission android:name="com.sonyericsson.extras.liveware.aef.EXTENSION_PERMISSION" />
<uses-permission android:name="com.sony.smarteyeglass.permission.SMARTEYEGLASS" />
<!-- This is permission of Text Input functionality as i used for first Sample. you should modify it based on which API want to use -->
<uses-permission android:name="com.sony.smarteyeglass.permission.VOICE_TEXT_INPUT" />

II. Define BroadCast-Receiver to Handle Each Intent-Filter Actions & Invoke the Service.

<receiver android:name="com.example.sony.smarteyeglass.extension.samplevoicetextinput.ExtensionReceiver" >
<intent-filter>

<!-- Generic extension intents. -->
<action android:name="com.sonyericsson.extras.liveware.aef.registration.EXTENSION_REGISTER_REQUEST"/>
<action android:name="com.sonyericsson.extras.liveware.aef.registration.ACCESSORY_CONNECTION" />
<action android:name="android.intent.action.LOCALE_CHANGED" />

<!-- Notification intents -->
<action android:name="com.sonyericsson.extras.liveware.aef.notification.VIEW_EVENT_DETAIL" />
<action android:name="com.sonyericsson.extras.liveware.aef.notification.REFRESH_REQUEST" />

<!-- Widget intents -->
<action android:name="com.sonyericsson.extras.aef.widget.START_REFRESH_IMAGE_REQUEST" />
<action android:name="com.sonyericsson.extras.aef.widget.STOP_REFRESH_IMAGE_REQUEST" />
<action android:name="com.sonyericsson.extras.aef.widget.ONTOUCH" />
<action android:name="com.sonyericsson.extras.liveware.extension.util.widget.scheduled.refresh" />

<!-- Control intents -->
<action android:name="com.sonyericsson.extras.aef.control.START" />
<action android:name="com.sonyericsson.extras.aef.control.STOP" />
<action android:name="com.sonyericsson.extras.aef.control.PAUSE" />
<action android:name="com.sonyericsson.extras.aef.control.RESUME" />
<action android:name="com.sonyericsson.extras.aef.control.ERROR" />
<action android:name="com.sonyericsson.extras.aef.control.KEY_EVENT" />
<action android:name="com.sonyericsson.extras.aef.control.TOUCH_EVENT" />
<action android:name="com.sonyericsson.extras.aef.control.SWIPE_EVENT" />
</intent-filter>
</receiver>

III. Now Need a Class extended of ExtensionService

<service android:name="com.example.sony.smarteyeglass.extension.samplevoicetextinput.SampleExtensionService" />

Save the Manifest And let check each classes.

IV. As you know the first thing class is BroadcastReceiver

This Class Receive the Broadcast message and invoke the a Service to Handle Other events.

@Override
public void onReceive(final Context context, final Intent intent) {
intent.setClass(context, SampleExtensionService.class);
context.startService(intent);
}

V. ExtensionService class.

The Registration is invoke the API Handler class extended from RegistrationInformation that Check required info & configuration.

from Display Info to API Info

for this Sample SampleRegistrationInformation extends RegistrationInformation to identify extension you should check;

/** Uses control API version*/
private static final int CONTROL_API_VERSION = 4;
@Override
public int getRequiredControlApiVersion() {
return [B]CONTROL_API_VERSION[/B];
}

So cause this is not Notification Or Sensor Based API that used in this sample you will have this

@Override
public int getRequiredSensorApiVersion() {

return RegistrationInformation.[B]API_NOT_REQUIRED[/B];
}

@Override
public int getRequiredNotificationApiVersion() {

return RegistrationInformation.[B]API_NOT_REQUIRED[/B];
}

* IF you want to use Notification API you should define it like this

@Override
public int getRequiredNotificationApiVersion() {
// Notification API level
return [B]1[/B];
}

Finally in this class you should invoke the Controller Class. (control extension handles a control on an accessory.)

@Override
public ControlExtension createControlExtension(final String hostAppPackageName) {
return new SampleVoiceTextInputControl(this, hostAppPackageName);
}

VI. ControlExtension class

It s similar to Other Controller class that actually known as Event Handler/Listener.

- First define parameter to get instance of utility & hardware side

/** Instance of the Control Utility class. */

//The control extension handles a control on an accessory

private final [B]SmartEyeglassControlUtils[/B] utils;

to get instance of microphone & return the results.

- After this it s time to create Listener & get Result;

final SmartEyeglassEventListener listener = new SmartEyeglassEventListener(){
@Override
public void onDialogClosed(final int code) {
Log.d(Constants.LOG_TAG, "onDialogClosed() : " + code);
}

@Override
public void onVoiceTextInput(final int errorcode, final String text) {
String message;
if (errorcode == 0) { //errorcode == 0 means Successful operation.
[COLOR=Red][B] // And Here
//You get the test Result & can add an operation you like.
//simple Toast notification or invoking another class & ...[/B][/COLOR]
message = "Inputted text : " + text;
Toast.makeText(c, text, Toast.LENGTH_SHORT).show();
}
else {
message = "Text Input Canceled";
Toast.makeText(c, message, Toast.LENGTH_SHORT).show();
}
utils.showDialogMessage(message, SmartEyeglassControl.Intents.DIALOG_MODE_OK);
}
};
utils = new SmartEyeglassControlUtils(hostAppPackageName, listener);
utils.activate(context);

- At the end you must deactive System Utils to allow other extension or apps use it.

@Override
public void onDestroy() {
utils.deactivate();
};

VII. This sample finished. + By Checking each class you will get more things to understand.

So Open Sample Code & Check it carefully.

3. Test App

1. Download & Install SmartEyeglassEmulator.apk + SmartEyeglass.apk from Attachments

2. Open the SmartEyeglassEmulator app

3. Swipe Left/Right on green area to find Installed App & Click on Touch Sensor button to Select.

OOOOOOO

​

The explanations of codes are available inside each classes.

​

Tutorial & Sample Codes for

- SmartWatches (Android-Wear)

Coming Soon...

​

Don't forget to Hit Thanks
​

​

[/LEFT]

[/CENTER]