Sony Ericsson LiveView SDK and my Alarm Clock Plugin

So as I mentioned in a previous post I recently got a Sony Ericson LiveView watch, I decided to download the SDK and have a go at writing a plugin for use with the watch. The SDK is easy to use (developer world) and the examples and documentation (available here) is very clear and easy to understand. Unfortunately there is no emulator so you will have to go to the trouble of owning one of these devices if you want to test your app on it.

There are two types of plugins.
1. Announce plug-in

Announce plug-ins can send announcements to the LiveView™ device. This is done in
the same way as the predefined announce features, like Facebook and Twitter.

Gmail Plugin Emails

Gmail Plugin Emails

The SDK Announce plugin (helloWorldPlugin) example is very simple and and mostly contains code scheduling a timer to send events to the phone along. This is a single class which is supported by a small number of helper classes and the plugin only contains a few things foreign to a typical android application:

Just extend the class provided by the SDK for plugins:

public class HelloWorldService extends AbstractPluginService {

Send updates to the phone using the following function:

mLiveViewAdapter.sendAnnounce(mPluginId, mMenuIcon, header, body, System.currentTimeMillis(), "");

mPluginId – identifies which app send the update
mMenuIcon – the icon the update will appear with
header – the title (IE: email subject)
body – the main text (IE: email text)
timestamp – timestamp of the announcement
link – action to perform when user clicks at end of message (event to occur on phone). This is interpreted by overriding the function below:

	protected void openInPhone(String openInPhoneAction) {
		Log.d(PluginConstants.LOG_TAG, "openInPhone: " + openInPhoneAction);
		// Open in browser.
		final Uri uri = Uri.parse(openInPhoneAction);
		final Intent browserIntent = new Intent();
		browserIntent.setClassName("", "");

2. Sandbox

The sandbox plug-in can take complete control of the LiveView™ device by sending
images to it and control its ability to vibrate and display different colors on the LED. All
user activities are propagated to the plug-in, so that it can take appropriate actions.

Contact Call Plugin

Contact Call Plugin

We extend the same class however this time we say yes when we are asked if we are a sandbox plugin:

	protected boolean isSandboxPlugin() {
        return true;

So now rather than using sendAnnounce to send text to the liveview we directly send images. Below is a function used that draws some text to a bitmap and then sends it to be displayed.

    public static void sendTextBitmap(LiveViewAdapter liveView, int pluginId, String text, int bitmapSizeX, int fontSize) {
        // Empty bitmap and link the canvas to it
        Bitmap bitmap = null;
        try {
            bitmap = Bitmap.createBitmap(bitmapSizeX, fontSize, Bitmap.Config.RGB_565);
        catch(IllegalArgumentException  e) {
        Canvas canvas = new Canvas(bitmap);

        // Set the text properties in the canvas
        TextPaint textPaint = new TextPaint();

        // Create the text layout and draw it to the canvas
        Layout textLayout = new StaticLayout(text, textPaint, bitmapSizeX, Layout.Alignment.ALIGN_CENTER, 1, 1, false);
            liveView.sendImageAsBitmap(pluginId, centerX(bitmap), centerY(bitmap), bitmap);
        } catch(Exception e) {
            Log.d(PluginConstants.LOG_TAG, "Failed to send bitmap", e);

So we can create a similar function drawing whatever we want to a bitmap and then passing it onto the screen.

Only one thing left (I think). Intercepting button presses:

	protected void button(String buttonType, boolean doublepress, boolean longpress) {

Where the the following buttons are defined:

  • PluginConstants.BUTTON_UP
  • PluginConstants.BUTTON_DOWN
  • PluginConstants.BUTTON_LEFT
  • PluginConstants.BUTTON_RIGHT
  • PluginConstants.BUTTON_SELECT

and we can see if the were tapped or held down with the boolean longpress. Note that we cannot detect longpresses of select as that will exit your plugin and the power button at all as that controls the screen.

My Attempt at a plugin: Alarm Clock
So I thought given that this thing is pretty much a watch, it would be useful to be able to set an alarm with it.

Plugin Icon

Plugin Icon

12hr clock (select sets alarm)

12hr clock (select sets alarm)

24hr clock

24hr clock

Unfortunately I don’t think it is possible to set the alarm programatically in android in versions prior to gingerbread (posted a stackoverflow question about it). So the user base is very limited, only users with gingerbread and higher with a LiveView will be able to use it so I don’t expect a massive response. Also I have no idea if this will work with non-stock alarm clock apps as I’m not aware of any manufacturers modification of gingerbread as of yet.

The LiveView application on the phone handles links to all the shared preferences for the plugins (they’re mandatory just for the enable/disable option) but an example is included in all the examples and it is very simple to just add more options to the preferences.xml and grab them in the code.

LiveView plugin settings

LiveView plugin settings

Alarm set via plugin

Alarm set via plugin

If you want more info please read the documentation linked at the start of this post. I will probably release the liveview alarm clock plugin onto the market soon, but I don’t expect the reception to be that good as it will only work on a few phones / tablets. Anyway I had fun programming for mine, enjoy!


  1. […] my previous two posts about Sony Ericssons LiveView (Quick Review and SDK & development) I have released my Alarm Clock Plugin for Sony Ericsson […]

  2. Jon


    Could you upload the alarm source please?


  3. Elroid

    Hey, well done for actually doing this! I got myself a liveview as well, but the thing is so flakey that i barely use it, and haven’t gotten around to programming for it yet (though that was my intention!) Happy to give your code a try sometime though.
    Incidentally, regarding your alarm clock issue, it might be an idea to get in touch with the makers of Gentle Alarm ( ) – what i think is probably the best alarm clock on android (if not the world). They might be happy to make an intent available to set an alarm time….

  4. Tom

    Are you interested in contract work developing a plug-in for me; it would be fairly simple, just a few screens I have no tools for Android development, and no background developing on Android/Java, but I have lots of programming background and did manage to make a robust App with the Scratch-like AppInventor. Now I just want to hook it to a LiveView plug-in. I would rather not go through the learning curve for a DYI implementation particularly as the plug-in is just a small part of the project.

  5. Matt

    Hi, can i get or build a yahoo email plugin? I dont use gmail so there should be a plugin to set your default email or multiple email addresses! Thanks for the info!

  6. legal amphetamines

    These are really fantastic ideas in concerning blogging. You have touched some good points here.
    Any way keep up wrinting.

  7. minecraft

    I like the helpful info you supply on your articles. I’ll bookmark your blog and take a look at again right here regularly. I am slightly sure I’ll be informed a lot of new stuff
    proper right here! Best of luck for the following!

Leave a Comment

Your email address will not be published. Required fields are marked *