Sony Addon SDK public class

NotificationWidgetExtension

This project is no longer being supported and will not get any further updates.
extends WidgetExtension
  1. java.lang.Object
  2. com.sonyericsson.extras.liveware.extension.util.widget.WidgetExtension
  3. com.sonyericsson.extras.liveware.extension.util.widget.NotificationWidgetExtension

Class Overview

The widget extension handles a widget on an accessory.

Summary

Constants
int REQUIRED_API_VERSION
Inherited Constants
From class WidgetExtension
java.lang.String SCHEDULED_REFRESH_INTENT
int WIDGET_WIDTH_SMARTWATCH Widget width in pixels in the original SmartWatch.
int WIDGET_HEIGHT_SMARTWATCH Widget height in pixels in the original SmartWatch.
int NOT_SET
Fields
protected static final java.lang.String[] EVENT_PROJECTION
protected final int mNoEventsTextResourceId
protected final int mDefaultSourceIconResourceId
protected final Handler mHandler
protected final java.lang.String mExtensionKey
protected NotificationWidgetEvent mLastEvent
Inherited Fields
From class WidgetExtension
protected final Context mContext The extension service context.
protected final java.lang.String mHostAppPackageName The host app package name with which the widget is connected.
protected int mInstanceId Widget instance Id.
Public Constructors
NotificationWidgetExtension(Context context, Handler handler, java.lang.String hostAppPackageName, java.lang.String extensionKey, int noEventsTextResourceid, int defaultSourceIconResourceId)

Create notification extension widget.

Public Methods
static int getSupportedWidgetWidth(Context context)

Get supported widget width.

static int getSupportedWidgetHeight(Context context)

Get supported widget height.

void onScheduledRefresh()
void onStartRefresh()

Start refreshing the widget.

void onStopRefresh()

Stop refreshing the widget.

void onTouch(int type, int x, int y)

The widget has been touched.

Bitmap getBitmap(NotificationWidgetEvent event)

Create a bitmap from notification event.

Protected Methods
void updateWidget(boolean checkEvent)

Update widget.

NotificationWidgetEvent getEvent()

Get the widget event to show.

Cursor getEventCursor()

Get the event cursor for most relevant event, defined as: the event with the lowest PUBLISHED_TIME with PUBLISHED_TIME > current time.

int getCount()

Get the number of new events.

java.lang.String getSourceIconUri(long sourceId)

Get the source icon uri for a source id.

java.lang.String getNoEventsText()

Get the text to show in the no events widget.

Inherited Methods
From class WidgetExtension
final void startRefresh()

Start widget refresh.

final void stopRefresh()

Stop widget refresh.

final void destroy()

Destroy widget.

abstract void onStartRefresh()

Called when widgets starts refreshing and is visible.

abstract void onStopRefresh()

Called when widget stops refreshing and is no longer visible.

void onScheduledRefresh()

Override this method to take action on scheduled refresh.

void onDoAction(int requestCode, Bundle bundle)

Called when widget receives an action request.

void onDestroy()

Called when a widget is no longer used and is being removed.

void onTouch(int type, int x, int y)

Called when the widget has been touched.

void onObjectClick(int type, int layoutReference)

Called when an object click event has occurred.

void scheduleRepeatingRefresh(long triggerAtTime, long interval, java.lang.String extensionKey)

Schedule a repeating refresh.

void scheduleRefresh(long triggerAtTime, java.lang.String extensionKey)

Schedule a refresh.

void cancelScheduledRefresh(java.lang.String extensionKey)

Cancel any pending scheduled refresh associated with the extension key.

void sendImageToHostApp(int resourceId)

Show image in the widget.

void sendToHostApp(Intent intent)

Send intent to host application.

void showBitmap(Bitmap bitmap)

Show bitmap in the widget.

void showLayout(int layoutId)

Show a layout in the widget.

void showLayout(int layoutId, Bundle[] layoutData)

Show a layout in the widget.

void showLayout(int layoutId, int noTouchLayoutId, Bundle[] layoutData)

Show a layout in the widget.

void showLayout(int layoutId, int noTouchLayoutId, int offLineLayoutId, Bundle[] layoutData)

Show a layout in the widget.

void sendImage(int layoutReference, int resourceId)

Update an image in a specific layout, in the widget.

void sendText(int layoutReference, java.lang.String text)

Update a TextView in a specific layout, in the widget.

Constants

public static final int REQUIRED_API_VERSION

Constant Value: 1 (0x00000001)

Fields

protected static final java.lang.String[] EVENT_PROJECTION

protected final int mNoEventsTextResourceId

protected final int mDefaultSourceIconResourceId

protected final Handler mHandler

protected final java.lang.String mExtensionKey

protected NotificationWidgetEvent mLastEvent

Public Constructors

public NotificationWidgetExtension(Context context, Handler handler, java.lang.String hostAppPackageName, java.lang.String extensionKey, int noEventsTextResourceid, int defaultSourceIconResourceId)

Create notification extension widget.

Parameters
context The context.
handler The handler.
hostAppPackageName The host app package name for this widget.
extensionKey The extension key.
noEventsTextResourceid The resource id of the string to show in the no events widget.
defaultSourceIconResourceId The resource if of the image to show when there are no events

Public Methods

public static int getSupportedWidgetWidth(Context context)

Get supported widget width.

Parameters
context The context.
Returns

the width.

public static int getSupportedWidgetHeight(Context context)

Get supported widget height.

Parameters
context The context.
Returns

the height.

public void onScheduledRefresh()

Overrides

public void onStartRefresh()

Start refreshing the widget. The widget is now visible.

Overrides

public void onStopRefresh()

Stop refreshing the widget. The widget is no longer visible.

Overrides

public void onTouch(int type, int x, int y)

The widget has been touched.

Overrides

onTouch in WidgetExtension

Parameters
type The type of touch event.
x The x position of the touch event.
y The y position of the touch event.

public Bitmap getBitmap(NotificationWidgetEvent event)

Create a bitmap from notification event.

Parameters
event The event or null if no events.
Returns

the bitmap to send to the host application.

Protected Methods

protected void updateWidget(boolean checkEvent)

Update widget.

Parameters
checkEvent True if we shall check if the event is new before we update. False to disable check.

protected NotificationWidgetEvent getEvent()

Get the widget event to show.

Returns

The widget event to show.

protected Cursor getEventCursor()

Get the event cursor for most relevant event, defined as: the event with the lowest PUBLISHED_TIME with PUBLISHED_TIME > current time. If no such event choose the event with highest PUBLISHED_TIME.

Returns

The event cursor for the event

protected int getCount()

Get the number of new events.

Returns

The number of new events.

protected java.lang.String getSourceIconUri(long sourceId)

Get the source icon uri for a source id.

Parameters
sourceId The source id.
Returns

The source icon uri.

protected java.lang.String getNoEventsText()

Get the text to show in the no events widget.

Returns

The text to show in the no events widget.