1# Starting a ServiceAbility 2 3 4A ServiceAbility is started in the same way other abilities. You can start a ServiceAbility by calling **featureAbility.startAbility()** in the PageAbility or calling **particleAbility.startAbility()** in another ServiceAbility. For details about the startup rules, see [Component Startup Rules](component-startup-rules.md). 5 6 7The following example shows how to use **startAbility()** to start the ServiceAbility whose **bundleName** is **com.example.myapplication** and **abilityName** is **ServiceAbility** in a PageAbility. When starting the ServiceAbility, concatenate the **bundleName** string before **abilityName**. 8 9```ts 10import featureAbility from '@ohos.ability.featureAbility'; 11import Want from '@ohos.app.ability.Want'; 12import promptAction from '@ohos.promptAction'; 13import hilog from '@ohos.hilog'; 14 15const TAG: string = 'PageServiceAbility'; 16const domain: number = 0xFF00; 17 18@Entry 19@Component 20struct PageServiceAbility { 21 async startServiceAbility(): Promise<void> { 22 try { 23 hilog.info(domain, TAG, 'Begin to start ability'); 24 let want: Want = { 25 bundleName: 'com.samples.famodelabilitydevelop', 26 abilityName: 'com.samples.famodelabilitydevelop.ServiceAbility' 27 }; 28 await featureAbility.startAbility({ want }); 29 promptAction.showToast({ 30 message: 'start_service_success_toast' 31 }); 32 hilog.info(domain, TAG, `Start ability succeed`); 33 } catch (error) { 34 hilog.error(domain, TAG, 'Start ability failed with ' + error); 35 } 36 } 37 build() { 38 // ... 39 } 40} 41``` 42 43 44In the preceding code, [startAbility()](../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is used to start the ServiceAbility. 45 46 47- If the ServiceAbility is not running, the system calls **onStart()** to initialize the ServiceAbility, and then calls **onCommand()** on the ServiceAbility. 48 49- If the ServiceAbility is running, the system directly calls **onCommand()** on the ServiceAbility. 50