> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Ability的上下文环境,继承自Context。
Implements ability context. This module is inherited from **Context**.
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Extension的上下文环境,继承自Context。
Implements extension context. This module is inherited from **Context**.
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
-返回值
| 类型 | 说明 |
-Return value
| Type| Description|
| -------- | -------- |
| number | 返回一个number,后续根据这个number去断开连接。 |
| number | A number, based on which the connection will be interrupted.|
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
提供ServiceExtension服务扩展相关接口。
Provides APIs related to **ServiceExtension**.
## 导入模块
## Modules to Import
```
import ServiceExtension from '@ohos.application.ServiceExtension';
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
## onCreate
onCreate(want: Want): void;
Extension生命周期回调,在创建时回调,执行初始化业务逻辑操作。
Called when an extension is created to initialize the service logic.
Called after **onCreate** is invoked when an ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started.
| startId | number | 是 | 返回拉起次数。首次拉起初始值返回1,多次之后自动递增。 |
| want | [Want](js-apis-featureAbility.md#Want)| Yes| Information related to this extension, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
Called after **onCreate** is invoked when an ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client.