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. |
Constant Value: -1 (0xffffffffffffffff)
Registration information with the extension capabilities and requirements.
Create instance of ExtensionService
extensionKey | The extension key. |
---|
Create instance of ExtensionService. This constructor does not include an extension key so getExtensionKey must be implemented if it's used.
intent | |
---|---|
startId |
intent | |
---|---|
flags | |
startId |
onlySources | |
---|---|
success |
Called after extension registration Override this method if you want to take actions after registration.
success |
---|
Called after source registration has been refreshed. Override this method if you want to take actions after a source registration refresh.
success | True on source registration refresh success. |
---|
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.
hostAppPackageName | The package name of the host application that the widget will be shown on. |
---|
The widget extension.
Trigger action for all widgets. Use this method to take the same action on all widgets.
requestCode | Code defined by the caller used to distinguish between different actions. |
---|---|
bundle | Optional bundle with additional information. |
Trigger action on a widget.
requestCode | Code defined by the caller used to distinguish between different actions. |
---|---|
hostAppPackageName | The host app package name. |
bundle | Optional bundle with additional information. |
Destroy all widgets. Inform all widgets that they shall free any resources such as threads and registered broad cast receivers.
Create control extension. Override this method to provide extension control.
hostAppPackageName | The host application package name. |
---|
The control extension.
Trigger action for all controls. Use this method to take the same action on all controls.
requestCode | Code defined by the caller used to distinguish between different actions. |
---|---|
bundle | Optional bundle with additional information. |
Trigger action on a control.
requestCode | Code defined by the caller used to distinguish between different actions. |
---|---|
hostAppPackageName | The host app package name. |
bundle | Optional bundle with additional information. |
Destroy all controls. Inform all controls that they shall free any resources such as threads and registered broad cast receivers.
intent |
---|
intentSender |
---|
intent |
---|
intent | |
---|---|
receiverPermission |
Handle intent received by extension service.
intent | The intent. |
---|
Called when locale is changed. Default implementation performs extension registration in background.
Called when accessory is connected/disconnected.
connected |
---|
Called when registration is requested. Default implementation performs extension registration in background.
Perform extension registration in background.
onlySources | True if only sources shall be refreshed. False for full registration update. |
---|
Handle VIEW_EVENT_INTENT. Override this method if this is a notification extension
intent | The view intent |
---|
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
Provides the extension registration information. This method has to be implemented for all extensions.
The extension registration information.
Shall the extension service be kept running as long as an accessory is connected.
True if the service shall be kept running as long an accessory is connected.
Stop the service if there is no activities that requires the service to be running.
Check in the database if there are any accessories connected.
True if at least one accessories is connected.
Send control start request.
hostAppPackageName | The host application package to start a control for. |
---|
A control error occurred and there is no control started for the host application.
hostAppPackageName | The host application package name. |
---|---|
errorCode | The error code. EXTRA_ERROR_CODE |
The extension service is an abstract class that should be extended for accessory extensions.