1e41f4b71Sopenharmony_ci# @ohos.ability.particleAbility (ParticleAbility)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **particleAbility** module provides APIs for operating a DataAbility and ServiceAbility. You can use the APIs to start and terminate a ParticleAbility, obtain a **dataAbilityHelper** object, and connect to or disconnect from a ServiceAbility.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci> 
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> 
9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the FA model.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Constraints
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciThe ParticleAbility module is used to perform operations on abilities of the Data and Service types.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Modules to Import
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci```ts
18e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
19e41f4b71Sopenharmony_ci```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## particleAbility.startAbility
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_cistartAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciStarts a ParticleAbility. This API uses an asynchronous callback to return the result.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci> **NOTE**
28e41f4b71Sopenharmony_ci>
29e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Parameters**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci| Name     | Type                                           | Mandatory | Description             |
36e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------- | ---- | ----------------- |
37e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes  | Ability to start. |
38e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<void>                            | Yes  | Callback used to return the result. If the ParticleAbility is started, **err** is **undefined**; otherwise, **err** is an error object. |
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**Example**
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
43e41f4b71Sopenharmony_ci```ts
44e41f4b71Sopenharmony_ciimport { particleAbility, wantConstant } from '@kit.AbilityKit';
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ciparticleAbility.startAbility(
47e41f4b71Sopenharmony_ci  {
48e41f4b71Sopenharmony_ci    want:
49e41f4b71Sopenharmony_ci    {
50e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
51e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
52e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
53e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
54e41f4b71Sopenharmony_ci      deviceId: '',
55e41f4b71Sopenharmony_ci      bundleName: 'com.example.Data',
56e41f4b71Sopenharmony_ci      abilityName: 'com.example.Data.EntryAbility',
57e41f4b71Sopenharmony_ci      uri: ''
58e41f4b71Sopenharmony_ci    },
59e41f4b71Sopenharmony_ci  },
60e41f4b71Sopenharmony_ci  (error, data) => {
61e41f4b71Sopenharmony_ci    if (error && error.code !== 0) {
62e41f4b71Sopenharmony_ci      console.error(`startAbility fail, error: ${JSON.stringify(error)}`);
63e41f4b71Sopenharmony_ci    } else {
64e41f4b71Sopenharmony_ci      console.log(`startAbility success, data: ${JSON.stringify(data)}`);
65e41f4b71Sopenharmony_ci    }
66e41f4b71Sopenharmony_ci  },
67e41f4b71Sopenharmony_ci);
68e41f4b71Sopenharmony_ci```
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci## particleAbility.startAbility
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_cistartAbility(parameter: StartAbilityParameter): Promise\<void>
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ciStarts a ParticleAbility. This API uses a promise to return the result.
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci> **NOTE**
77e41f4b71Sopenharmony_ci>
78e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**Parameters**
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| Name     | Type                                           | Mandatory | Description             |
85e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------- | ---- | ----------------- |
86e41f4b71Sopenharmony_ci| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes  | Ability to start. |
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Return value**
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci| Type          | Description                     |
91e41f4b71Sopenharmony_ci| -------------- | ------------------------- |
92e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the result. Promise that returns no value. |
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Example**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
97e41f4b71Sopenharmony_ci```ts
98e41f4b71Sopenharmony_ciimport { particleAbility, wantConstant } from '@kit.AbilityKit';
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ciparticleAbility.startAbility(
101e41f4b71Sopenharmony_ci  {
102e41f4b71Sopenharmony_ci    want:
103e41f4b71Sopenharmony_ci    {
104e41f4b71Sopenharmony_ci      action: 'ohos.want.action.home',
105e41f4b71Sopenharmony_ci      entities: ['entity.system.home'],
106e41f4b71Sopenharmony_ci      type: 'MIMETYPE',
107e41f4b71Sopenharmony_ci      flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
108e41f4b71Sopenharmony_ci      deviceId: '',
109e41f4b71Sopenharmony_ci      bundleName: 'com.example.Data',
110e41f4b71Sopenharmony_ci      abilityName: 'com.example.Data.EntryAbility',
111e41f4b71Sopenharmony_ci      uri: ''
112e41f4b71Sopenharmony_ci    },
113e41f4b71Sopenharmony_ci  },
114e41f4b71Sopenharmony_ci).then(() => {
115e41f4b71Sopenharmony_ci  console.info('particleAbility startAbility');
116e41f4b71Sopenharmony_ci});
117e41f4b71Sopenharmony_ci```
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci## particleAbility.terminateSelf
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_citerminateSelf(callback: AsyncCallback\<void>): void
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ciTerminates this ParticleAbility. This API uses an asynchronous callback to return the result.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Parameters**
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci| Name    | Type                | Mandatory | Description                |
130e41f4b71Sopenharmony_ci| -------- | -------------------- | ---- | -------------------- |
131e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the ParticleAbility is terminated, **err** is **undefined**; otherwise, **err** is an error object. |
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**Example**
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
136e41f4b71Sopenharmony_ci```ts
137e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciparticleAbility.terminateSelf(
140e41f4b71Sopenharmony_ci  (error) => {
141e41f4b71Sopenharmony_ci    if (error && error.code !== 0) {
142e41f4b71Sopenharmony_ci      console.error(`terminateSelf fail, error: ${JSON.stringify(error)}`);
143e41f4b71Sopenharmony_ci    }
144e41f4b71Sopenharmony_ci  }
145e41f4b71Sopenharmony_ci);
146e41f4b71Sopenharmony_ci```
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci## particleAbility.terminateSelf
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_citerminateSelf(): Promise\<void>
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciTerminates this ParticleAbility. This API uses a promise to return the result.
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci**Return value**
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci| Type          | Description                     |
159e41f4b71Sopenharmony_ci| -------------- | ------------------------- |
160e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the result. Promise that returns no value. |
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci**Example**
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
165e41f4b71Sopenharmony_ci```ts
166e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ciparticleAbility.terminateSelf().then(() => {
169e41f4b71Sopenharmony_ci  console.info('particleAbility terminateSelf');
170e41f4b71Sopenharmony_ci});
171e41f4b71Sopenharmony_ci```
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci## particleAbility.acquireDataAbilityHelper
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ciacquireDataAbilityHelper(uri: string): DataAbilityHelper
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ciObtains a **dataAbilityHelper** object.
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci> **NOTE**
182e41f4b71Sopenharmony_ci>
183e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
184e41f4b71Sopenharmony_ci> To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**Parameters**
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci| Name | Type  | Mandatory | Description                    |
191e41f4b71Sopenharmony_ci| :--- | ------ | ---- | ------------------------ |
192e41f4b71Sopenharmony_ci| uri  | string | Yes  | URI of the file to open. |
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci**Return value**
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci| Type             | Description                                        |
197e41f4b71Sopenharmony_ci| ----------------- | -------------------------------------------- |
198e41f4b71Sopenharmony_ci| [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | A utility class used to help other abilities access a DataAbility. |
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**Example**
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
203e41f4b71Sopenharmony_ci```ts
204e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_cilet uri = '';
207e41f4b71Sopenharmony_ciparticleAbility.acquireDataAbilityHelper(uri);
208e41f4b71Sopenharmony_ci```
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci## particleAbility.startBackgroundRunning<sup>(deprecated)</sup>
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_cistartBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback&lt;void&gt;): void
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciRequests a continuous task from the system. This API uses an asynchronous callback to return the result.
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci**NOTE**
222e41f4b71Sopenharmony_ci>
223e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [backgroundTaskManager.startBackgroundRunning](../apis-backgroundtasks-kit/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning) instead.
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**Parameters**
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci  | Name | Type | Mandatory | Description |
228e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
229e41f4b71Sopenharmony_ci  | id | number | Yes | Notification ID of the continuous task. |
230e41f4b71Sopenharmony_ci  | request | [NotificationRequest](../apis-notification-kit/js-apis-notification.md#notificationrequest) | Yes | Notification parameter, which is used to display information in the notification bar. |
231e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the continuous task is requested, **err** is **undefined**. Otherwise, **err** is an error object. |
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci **Example**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
236e41f4b71Sopenharmony_ci```ts
237e41f4b71Sopenharmony_ciimport { particleAbility, wantAgent } from '@kit.AbilityKit';
238e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
239e41f4b71Sopenharmony_ciimport notification from '@ohos.notification';
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_cifunction callback(error: BusinessError, data: void) {
242e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
243e41f4b71Sopenharmony_ci    console.error(`Operation failed error: ${JSON.stringify(error)}`);
244e41f4b71Sopenharmony_ci  } else {
245e41f4b71Sopenharmony_ci    console.info(`Operation succeeded, data: ${data}`);
246e41f4b71Sopenharmony_ci  }
247e41f4b71Sopenharmony_ci}
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_cilet wantAgentInfo: wantAgent.WantAgentInfo = {
250e41f4b71Sopenharmony_ci  wants: [
251e41f4b71Sopenharmony_ci    {
252e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
253e41f4b71Sopenharmony_ci      abilityName: 'EntryAbility'
254e41f4b71Sopenharmony_ci    }
255e41f4b71Sopenharmony_ci  ],
256e41f4b71Sopenharmony_ci  operationType: wantAgent.OperationType.START_ABILITY,
257e41f4b71Sopenharmony_ci  requestCode: 0,
258e41f4b71Sopenharmony_ci  wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
259e41f4b71Sopenharmony_ci};
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ciwantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
262e41f4b71Sopenharmony_ci  let id = 1;
263e41f4b71Sopenharmony_ci  particleAbility.startBackgroundRunning(id, {
264e41f4b71Sopenharmony_ci    content:
265e41f4b71Sopenharmony_ci    {
266e41f4b71Sopenharmony_ci      contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
267e41f4b71Sopenharmony_ci      normal:
268e41f4b71Sopenharmony_ci      {
269e41f4b71Sopenharmony_ci        title: 'title',
270e41f4b71Sopenharmony_ci        text: 'text'
271e41f4b71Sopenharmony_ci      }
272e41f4b71Sopenharmony_ci    },
273e41f4b71Sopenharmony_ci    wantAgent: wantAgentObj
274e41f4b71Sopenharmony_ci  }, callback);
275e41f4b71Sopenharmony_ci});
276e41f4b71Sopenharmony_ci```
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci## particleAbility.startBackgroundRunning<sup>(deprecated)</sup>
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_cistartBackgroundRunning(id: number, request: NotificationRequest): Promise&lt;void&gt;
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ciRequests a continuous task from the system. This API uses a promise to return the result.
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**NOTE**
289e41f4b71Sopenharmony_ci>
290e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [backgroundTaskManager.startBackgroundRunning](../apis-backgroundtasks-kit/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning-1) instead.
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Parameters**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
295e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
296e41f4b71Sopenharmony_ci| id | number | Yes | Notification ID of the continuous task. |
297e41f4b71Sopenharmony_ci| request | [NotificationRequest](../apis-notification-kit/js-apis-notification.md#notificationrequest) | Yes | Notification parameter, which is used to display information in the notification bar. |
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Return value**
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci| Type          | Description                     |
302e41f4b71Sopenharmony_ci| -------------- | ------------------------- |
303e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the result. Promise that returns no value. |
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci**Example**
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
308e41f4b71Sopenharmony_ci```ts
309e41f4b71Sopenharmony_ciimport { particleAbility, wantAgent } from '@kit.AbilityKit';
310e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
311e41f4b71Sopenharmony_ciimport notification from '@ohos.notification';
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_cilet wantAgentInfo: wantAgent.WantAgentInfo = {
314e41f4b71Sopenharmony_ci  wants: [
315e41f4b71Sopenharmony_ci    {
316e41f4b71Sopenharmony_ci      bundleName: 'com.example.myapplication',
317e41f4b71Sopenharmony_ci      abilityName: 'EntryAbility'
318e41f4b71Sopenharmony_ci    }
319e41f4b71Sopenharmony_ci  ],
320e41f4b71Sopenharmony_ci  operationType: wantAgent.OperationType.START_ABILITY,
321e41f4b71Sopenharmony_ci  requestCode: 0,
322e41f4b71Sopenharmony_ci  wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
323e41f4b71Sopenharmony_ci};
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ciwantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
326e41f4b71Sopenharmony_ci  let id = 1;
327e41f4b71Sopenharmony_ci  particleAbility.startBackgroundRunning(id, {
328e41f4b71Sopenharmony_ci    content:
329e41f4b71Sopenharmony_ci    {
330e41f4b71Sopenharmony_ci      contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
331e41f4b71Sopenharmony_ci      normal:
332e41f4b71Sopenharmony_ci      {
333e41f4b71Sopenharmony_ci        title: 'title',
334e41f4b71Sopenharmony_ci        text: 'text'
335e41f4b71Sopenharmony_ci      }
336e41f4b71Sopenharmony_ci    },
337e41f4b71Sopenharmony_ci    wantAgent: wantAgentObj
338e41f4b71Sopenharmony_ci  }).then(() => {
339e41f4b71Sopenharmony_ci    console.info('Operation succeeded');
340e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
341e41f4b71Sopenharmony_ci    console.error(`Operation failed cause: ${JSON.stringify(err)}`);
342e41f4b71Sopenharmony_ci  });
343e41f4b71Sopenharmony_ci});
344e41f4b71Sopenharmony_ci```
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci## particleAbility.cancelBackgroundRunning<sup>(deprecated)</sup>
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_cicancelBackgroundRunning(callback: AsyncCallback&lt;void&gt;): void
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ciRequests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result.
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**NOTE**
355e41f4b71Sopenharmony_ci>
356e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [backgroundTaskManager.stopBackgroundRunning](../apis-backgroundtasks-kit/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning) instead.
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci**Parameters**
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
361e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
362e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the continuous task is canceled, **err** is **undefined**. Otherwise, **err** is an error object. |
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**Example**
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
367e41f4b71Sopenharmony_ci```ts
368e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
369e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_cifunction callback(error: BusinessError, data: void) {
372e41f4b71Sopenharmony_ci  if (error && error.code !== 0) {
373e41f4b71Sopenharmony_ci    console.error(`Operation failed error: ${JSON.stringify(error)}`);
374e41f4b71Sopenharmony_ci  } else {
375e41f4b71Sopenharmony_ci    console.info(`Operation succeeded, data: ${data}`);
376e41f4b71Sopenharmony_ci  }
377e41f4b71Sopenharmony_ci}
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ciparticleAbility.cancelBackgroundRunning(callback);
380e41f4b71Sopenharmony_ci```
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci## particleAbility.cancelBackgroundRunning<sup>(deprecated)</sup>
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_cicancelBackgroundRunning(): Promise&lt;void&gt;
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ciRequests to cancel a continuous task from the system. This API uses a promise to return the result.
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**NOTE**
391e41f4b71Sopenharmony_ci>
392e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [backgroundTaskManager.stopBackgroundRunning](../apis-backgroundtasks-kit/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning-1) instead.
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci**Return value**
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci| Type          | Description                     |
397e41f4b71Sopenharmony_ci| -------------- | ------------------------- |
398e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the result. Promise that returns no value. |
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci **Example**
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
403e41f4b71Sopenharmony_ci```ts
404e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
405e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ciparticleAbility.cancelBackgroundRunning().then(() => {
408e41f4b71Sopenharmony_ci  console.info('Operation succeeded');
409e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
410e41f4b71Sopenharmony_ci  console.error(`Operation failed cause: ${JSON.stringify(err)}`);
411e41f4b71Sopenharmony_ci});
412e41f4b71Sopenharmony_ci```
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci## particleAbility.connectAbility
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ciconnectAbility(request: Want, options:ConnectOptions): number
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ciConnects this ability to a ServiceAbility.
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci> **NOTE**
421e41f4b71Sopenharmony_ci>
422e41f4b71Sopenharmony_ci> For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
423e41f4b71Sopenharmony_ci> To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci**Parameters**
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci| Name   | Type          | Mandatory | Description                        |
431e41f4b71Sopenharmony_ci| ------- | -------------- | ---- | ---------------------------- |
432e41f4b71Sopenharmony_ci| request | [Want](js-apis-application-want.md)           | Yes  | ServiceAbility to connect. |
433e41f4b71Sopenharmony_ci| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes  | Connection options.          |
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci**Return value**
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci| Type    | Description                  |
438e41f4b71Sopenharmony_ci| ------ | -------------------- |
439e41f4b71Sopenharmony_ci| number | ID of the connected ServiceAbility. The ID starts from 0 and is incremented by 1 each time a connection is set up. |
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**Example**
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
444e41f4b71Sopenharmony_ci```ts
445e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
446e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
447e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_cilet connId = particleAbility.connectAbility(
450e41f4b71Sopenharmony_ci  {
451e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
452e41f4b71Sopenharmony_ci    abilityName: 'ServiceAbilityA',
453e41f4b71Sopenharmony_ci  },
454e41f4b71Sopenharmony_ci  {
455e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
456e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
457e41f4b71Sopenharmony_ci    },
458e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
459e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId: ${element.deviceId}`);
460e41f4b71Sopenharmony_ci    },
461e41f4b71Sopenharmony_ci    onFailed: (code) => {
462e41f4b71Sopenharmony_ci      console.error(`particleAbilityTest ConnectAbility onFailed errCode: ${code}`);
463e41f4b71Sopenharmony_ci    },
464e41f4b71Sopenharmony_ci  },
465e41f4b71Sopenharmony_ci);
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ciparticleAbility.disconnectAbility(connId).then((data) => {
468e41f4b71Sopenharmony_ci  console.log(`data: ${data}`);
469e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
470e41f4b71Sopenharmony_ci  console.error(`particleAbilityTest result errCode: ${error.code}`);
471e41f4b71Sopenharmony_ci});
472e41f4b71Sopenharmony_ci```
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci## particleAbility.disconnectAbility
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_cidisconnectAbility(connection: number, callback:AsyncCallback\<void>): void
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ciDisconnects this ability from a specific ServiceAbility. This API uses an asynchronous callback to return the result.
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**Parameters**
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci  | Name | Type | Mandatory | Description |
485e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
486e41f4b71Sopenharmony_ci  | connection | number               | Yes   | ID of the ServiceAbility to disconnect. |
487e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the disconnection is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci**Example**
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
492e41f4b71Sopenharmony_ci```ts
493e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
494e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_cilet connId = particleAbility.connectAbility(
497e41f4b71Sopenharmony_ci  {
498e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
499e41f4b71Sopenharmony_ci    abilityName: 'ServiceAbilityA',
500e41f4b71Sopenharmony_ci  },
501e41f4b71Sopenharmony_ci  {
502e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
503e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
504e41f4b71Sopenharmony_ci    },
505e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
506e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId: ${element.deviceId}`);
507e41f4b71Sopenharmony_ci    },
508e41f4b71Sopenharmony_ci    onFailed: (code) => {
509e41f4b71Sopenharmony_ci      console.error(`particleAbilityTest ConnectAbility onFailed errCode: ${code}`);
510e41f4b71Sopenharmony_ci    },
511e41f4b71Sopenharmony_ci  },
512e41f4b71Sopenharmony_ci);
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ciparticleAbility.disconnectAbility(connId, (err) => {
515e41f4b71Sopenharmony_ci  console.error(`particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}`);
516e41f4b71Sopenharmony_ci});
517e41f4b71Sopenharmony_ci```
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci## particleAbility.disconnectAbility
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_cidisconnectAbility(connection: number): Promise\<void>
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ciDisconnects this ability from a specific ServiceAbility. This API uses a promise to return the result.
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci**Parameters**
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description |
531e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
532e41f4b71Sopenharmony_ci| connection | number               | Yes   | ID of the ServiceAbility to disconnect. |
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci**Return value**
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci| Type          | Description                     |
537e41f4b71Sopenharmony_ci| -------------- | ------------------------- |
538e41f4b71Sopenharmony_ci| Promise\<void> | Promise used to return the result. Promise that returns no value. |
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci**Example**
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
543e41f4b71Sopenharmony_ci```ts
544e41f4b71Sopenharmony_ciimport { particleAbility } from '@kit.AbilityKit';
545e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
546e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_cilet connId = particleAbility.connectAbility(
549e41f4b71Sopenharmony_ci  {
550e41f4b71Sopenharmony_ci    bundleName: 'com.ix.ServiceAbility',
551e41f4b71Sopenharmony_ci    abilityName: 'ServiceAbilityA',
552e41f4b71Sopenharmony_ci  },
553e41f4b71Sopenharmony_ci  {
554e41f4b71Sopenharmony_ci    onConnect: (element, remote) => {
555e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}`);
556e41f4b71Sopenharmony_ci    },
557e41f4b71Sopenharmony_ci    onDisconnect: (element) => {
558e41f4b71Sopenharmony_ci      console.log(`ConnectAbility onDisconnect element.deviceId: ${element.deviceId}`);
559e41f4b71Sopenharmony_ci    },
560e41f4b71Sopenharmony_ci    onFailed: (code) => {
561e41f4b71Sopenharmony_ci      console.error(`particleAbilityTest ConnectAbility onFailed errCode: ${code}`);
562e41f4b71Sopenharmony_ci    },
563e41f4b71Sopenharmony_ci  },
564e41f4b71Sopenharmony_ci);
565e41f4b71Sopenharmony_ci
566e41f4b71Sopenharmony_ciparticleAbility.disconnectAbility(connId).then(() => {
567e41f4b71Sopenharmony_ci  console.log('disconnectAbility success');
568e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
569e41f4b71Sopenharmony_ci  console.error(`particleAbilityTest result errCode : ${error.code}`);
570e41f4b71Sopenharmony_ci});
571e41f4b71Sopenharmony_ci```
572e41f4b71Sopenharmony_ci## ErrorCode
573e41f4b71Sopenharmony_ci
574e41f4b71Sopenharmony_ciEnumerates the error codes that may be returned when an ability is started.
575e41f4b71Sopenharmony_ci
576e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
577e41f4b71Sopenharmony_ci
578e41f4b71Sopenharmony_ci| Name                            | Value   | Description                                      |
579e41f4b71Sopenharmony_ci| ------------------------------ | ---- | ---------------------------------------- |
580e41f4b71Sopenharmony_ci| INVALID_PARAMETER | -1   | Invalid parameter. |
581