Sony Addon SDK public abstract class

ExtensionService

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

Class Overview

The extension service is an abstract class that should be extended for accessory extensions.

Summary

Nested Classes
interface ExtensionService.ExtensionIntentSender
class ExtensionService.LocalBinder Class used for the client Binder.
Constants
int INVALID_ID
Fields
protected RegistrationInformation mRegistrationInformation Registration information with the extension capabilities and requirements.
Public Constructors
ExtensionService(java.lang.String extensionKey)

Create instance of ExtensionService

Protected Constructors
ExtensionService()

Create instance of ExtensionService.

Public Methods
void onCreate()

void onStart(Intent intent, int startId)
int onStartCommand(Intent intent, int flags, int startId)
void onDestroy()

final void onExtensionRegisterResult(boolean onlySources, boolean success)
void onRegisterResult(boolean success)

Called after extension registration Override this method if you want to take actions after registration.

void onSourceRefreshResult(boolean success)

Called after source registration has been refreshed.

WidgetExtension createWidgetExtension(java.lang.String hostAppPackageName)

Create widget extension.

void doActionOnAllWidgets(int requestCode, Bundle bundle)

Trigger action for all widgets.

boolean doActionOnWidget(int requestCode, java.lang.String hostAppPackageName, Bundle bundle)

Trigger action on a widget.

void destroyAllWidgets()

Destroy all widgets.

ControlExtension createControlExtension(java.lang.String hostAppPackageName)

Create control extension.

void doActionOnAllControls(int requestCode, Bundle bundle)

Trigger action for all controls.

boolean doActionOnControl(int requestCode, java.lang.String hostAppPackageName, Bundle bundle)

Trigger action on a control.

void destroyAllControls()

Destroy all controls.

IBinder onBind(Intent intent)
void setIntentSender(ExtensionService.ExtensionIntentSender intentSender)
boolean onUnbind(Intent intent)
void sendBroadcast(Intent intent, java.lang.String receiverPermission)
Protected Methods
void handleIntent(Intent intent)

Handle intent received by extension service.

void onLocaleChanged()

Called when locale is changed.

void onConnectionChanged(boolean connected)

Called when accessory is connected/disconnected.

void onRegisterRequest()

Called when registration is requested.

void registerOrUpdate(boolean onlySources)

Perform extension registration in background.

void onViewEvent(Intent intent)

Handle VIEW_EVENT_INTENT.

void onRefreshRequest()

Handle REFRESH_REQUEST_INTENT.

abstract RegistrationInformation getRegistrationInformation()

Provides the extension registration information.

abstract boolean keepRunningWhenConnected()

Shall the extension service be kept running as long as an accessory is connected.

final void stopSelfCheck()

Stop the service if there is no activities that requires the service to be running.

boolean areAnyAccessoriesConnected()

Check in the database if there are any accessories connected.

void controlStartRequest(java.lang.String hostAppPackageName)

Send control start request.

void onControlError(java.lang.String hostAppPackageName, int errorCode)

A control error occurred and there is no control started for the host application.

Constants

public static final int INVALID_ID

Constant Value: -1 (0xffffffffffffffff)

Fields

protected RegistrationInformation mRegistrationInformation

Registration information with the extension capabilities and requirements.

Public Constructors

public ExtensionService(java.lang.String extensionKey)

Create instance of ExtensionService

Parameters
extensionKey The extension key.

Protected Constructors

protected ExtensionService()

Create instance of ExtensionService. This constructor does not include an extension key so getExtensionKey must be implemented if it's used.

Public Methods

public void onCreate()

See Also

public void onStart(Intent intent, int startId)

Parameters
intent
startId

public int onStartCommand(Intent intent, int flags, int startId)

Parameters
intent
flags
startId

public void onDestroy()

See Also

public final void onExtensionRegisterResult(boolean onlySources, boolean success)

Parameters
onlySources
success

public void onRegisterResult(boolean success)

Called after extension registration Override this method if you want to take actions after registration.

Parameters
success

public void onSourceRefreshResult(boolean success)

Called after source registration has been refreshed. Override this method if you want to take actions after a source registration refresh.

Parameters
success True on source registration refresh success.

public WidgetExtension createWidgetExtension(java.lang.String hostAppPackageName)

Create widget extension. Override this method to provide extension widgets. This method must be implemented when implementing widgets targeting widget API version 2 or lower.

Parameters
hostAppPackageName The package name of the host application that the widget will be shown on.
Returns

The widget extension.

See Also

public void doActionOnAllWidgets(int requestCode, Bundle bundle)

Trigger action for all widgets. Use this method to take the same action on all widgets.

Parameters
requestCode Code defined by the caller used to distinguish between different actions.
bundle Optional bundle with additional information.

public boolean doActionOnWidget(int requestCode, java.lang.String hostAppPackageName, Bundle bundle)

Trigger action on a widget.

Parameters
requestCode Code defined by the caller used to distinguish between different actions.
hostAppPackageName The host app package name.
bundle Optional bundle with additional information.

public void destroyAllWidgets()

Destroy all widgets. Inform all widgets that they shall free any resources such as threads and registered broad cast receivers.

public ControlExtension createControlExtension(java.lang.String hostAppPackageName)

Create control extension. Override this method to provide extension control.

Parameters
hostAppPackageName The host application package name.
Returns

The control extension.

See Also

public void doActionOnAllControls(int requestCode, Bundle bundle)

Trigger action for all controls. Use this method to take the same action on all controls.

Parameters
requestCode Code defined by the caller used to distinguish between different actions.
bundle Optional bundle with additional information.

public boolean doActionOnControl(int requestCode, java.lang.String hostAppPackageName, Bundle bundle)

Trigger action on a control.

Parameters
requestCode Code defined by the caller used to distinguish between different actions.
hostAppPackageName The host app package name.
bundle Optional bundle with additional information.

public void destroyAllControls()

Destroy all controls. Inform all controls that they shall free any resources such as threads and registered broad cast receivers.

public IBinder onBind(Intent intent)

Parameters
intent

public void setIntentSender(ExtensionService.ExtensionIntentSender intentSender)

Parameters
intentSender

public boolean onUnbind(Intent intent)

Parameters
intent

public void sendBroadcast(Intent intent, java.lang.String receiverPermission)

Parameters
intent
receiverPermission

Protected Methods

protected void handleIntent(Intent intent)

Handle intent received by extension service.

Parameters
intent The intent.

protected void onLocaleChanged()

Called when locale is changed. Default implementation performs extension registration in background.

See Also

protected void onConnectionChanged(boolean connected)

Called when accessory is connected/disconnected.

Parameters
connected

protected void onRegisterRequest()

Called when registration is requested. Default implementation performs extension registration in background.

See Also

protected void registerOrUpdate(boolean onlySources)

Perform extension registration in background.

Parameters
onlySources True if only sources shall be refreshed. False for full registration update.
See Also

protected void onViewEvent(Intent intent)

Handle VIEW_EVENT_INTENT. Override this method if this is a notification extension

Parameters
intent The view intent
See Also

protected void onRefreshRequest()

Handle REFRESH_REQUEST_INTENT. Sync extension data in this callback. This is only relevant for extensions that aren't always up to date, like polling extensions. Override this method if this is a notification extension

See Also

protected abstract RegistrationInformation getRegistrationInformation()

Provides the extension registration information. This method has to be implemented for all extensions.

Returns

The extension registration information.

protected abstract boolean keepRunningWhenConnected()

Shall the extension service be kept running as long as an accessory is connected.

Returns

True if the service shall be kept running as long an accessory is connected.

protected final void stopSelfCheck()

Stop the service if there is no activities that requires the service to be running.

protected boolean areAnyAccessoriesConnected()

Check in the database if there are any accessories connected.

Returns

True if at least one accessories is connected.

protected void controlStartRequest(java.lang.String hostAppPackageName)

Send control start request.

Parameters
hostAppPackageName The host application package to start a control for.

protected void onControlError(java.lang.String hostAppPackageName, int errorCode)

A control error occurred and there is no control started for the host application.

Parameters
hostAppPackageName The host application package name.
errorCode The error code. EXTRA_ERROR_CODE