Constants | ||
---|---|---|
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 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 | |
---|---|
WidgetExtension(Context context, java.lang.String hostAppPackageName)
Legacy constructor for widget extension. |
Public Methods | |
---|---|
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. |
Protected Methods | |
---|---|
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. |
Constant Value: "com.sonyericsson.extras.liveware.extension.util.widget.scheduled.refresh"
Widget width in pixels in the original SmartWatch.
Constant Value: 128 (0x00000080)
Widget height in pixels in the original SmartWatch.
Constant Value: 110 (0x0000006e)
Constant Value: -1 (0xffffffffffffffff)
The extension service context.
The host app package name with which the widget is connected.
Widget instance Id.
Legacy constructor for widget extension. does not guarantee all values for Widget API 3 are initialised
context | The context. |
---|---|
hostAppPackageName | Package name of host application. |
Start widget refresh.
Stop widget refresh.
Destroy widget.
Called when widgets starts refreshing and is visible.
Called when widget stops refreshing and is no longer visible.
Override this method to take action on scheduled refresh. Example of how to schedule a refresh every 10th second in onStartRefresh() and cancel it in onStopRefresh()
public void startRefresh() { // Update now and every 10th second scheduleRepeatingRefresh(System.currentTimeMillis(), 10 * 1000, SampleWidgetService.EXTENSION_KEY); } public void stopRefresh() { cancelScheduledRefresh(SampleWidgetService.EXTENSION_KEY); } public void onScheduledRefresh() { // Update widget... }
Called when widget receives an action request.
requestCode | Code used to distinguish between different actions. |
---|---|
bundle | Optional bundle with additional information. |
Called when a widget is no longer used and is being removed. The widget extension should clean up any resources it holds (threads, registered receivers, etc) at this point.
Called when the widget has been touched. Override to handle touch events.
type | The type of touch event. |
---|---|
x | The x position of the touch event. |
y | The y position of the touch event. |
Called when an object click event has occurred.
type | The type of click event |
---|---|
layoutReference | The referenced layout object |
Schedule a repeating refresh.
triggerAtTime | Time the scheduled refresh should trigger first time in System time. |
---|---|
interval | Interval between subsequent repeats of the scheduled refresh. |
extensionKey | The extension key |
Schedule a refresh.
triggerAtTime | Time the scheduled refresh should trigger in System time. |
---|---|
extensionKey | The extension key |
Cancel any pending scheduled refresh associated with the extension key.
extensionKey | The extension key |
---|
Show image in the widget.
resourceId | The image resource id. |
---|
Send intent to host application. Adds host application package name and our package name.
intent | The intent to send. |
---|
Show bitmap in the widget.
bitmap | The bitmap to show. |
---|
Show a layout in the widget.
layoutId | The layout resource id. |
---|
Show a layout in the widget.
layoutId | The layout resource id. |
---|---|
layoutData | The layout data. |
Show a layout in the widget.
layoutId | The layout resource id. |
---|---|
noTouchLayoutId | The layout resource id for a layout to display then touch is inactive but accessory is still connected to device |
layoutData | The layout data. Is applied to every layout provided |
Show a layout in the widget.
layoutId | The layout resource id. |
---|---|
noTouchLayoutId | The layout resource id for a layout to display then touch is inactive but accessory is still connected to device |
offLineLayoutId | The layout resource id for a layout to display when accessory is not connected to device |
layoutData | The layout data. Is applied to every layout provided |
Update an image in a specific layout, in the widget.
layoutReference | The referenced resource within the current layout. |
---|---|
resourceId | The image resource id. |
Update a TextView in a specific layout, in the widget.
layoutReference | The referenced resource within the current layout. |
---|---|
text | The text to be shown. |
The widget extension handles a widget on an accessory. Provides the information needed to register an extension widget. The information is used to populate the Registration.WidgetRegistration table