---
title: "actionStartService"
description: "Creates an [Action] that launches a [Service] from the given [Intent] when triggered. The intent
should specify a component with [Intent.setClass] or [Intent.setComponent]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


```kotlin
public fun actionStartService(intent: Intent, isForegroundService: Boolean = false): Action
```


Creates an `Action` that launches a `Service` from the given `Intent` when triggered. The intent
should specify a component with `Intent.setClass` or `Intent.setComponent`.

#### Parameters

| | |
| --- | --- |
| intent | the intent used to launch the activity |
| isForegroundService | set to true when the provided `Service` runs in foreground. This flag is only used for device versions after `android.os.Build.VERSION_CODES.O` that requires foreground service to be launched differently |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
public fun actionStartService(
    componentName: ComponentName,
    isForegroundService: Boolean = false,
): Action
```


Creates an `Action` that launches the `Service` specified by the given `ComponentName`.

#### Parameters

| | |
| --- | --- |
| componentName | component of the Service to launch |
| isForegroundService | set to true when the provided `Service` runs in foreground. This flag is only used for device versions after `android.os.Build.VERSION_CODES.O` that requires foreground service to be launched differently |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
public fun <T : Service> actionStartService(
    service: Class<T>,
    isForegroundService: Boolean = false,
): Action
```


Creates an `Action` that launches the specified `Service` when triggered.

#### Parameters

| | |
| --- | --- |
| service | class of the Service to launch |
| isForegroundService | set to true when the provided `Service` runs in foreground. This flag is only used for device versions after `android.os.Build.VERSION_CODES.O` that requires foreground service to be launched differently |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
public inline fun <reified T : Service> actionStartService(
    isForegroundService: Boolean = false
): Action
```


Creates an `Action` that launches the specified `Service` when triggered.

#### Parameters

| | |
| --- | --- |
| isForegroundService | set to true when the provided `Service` runs in foreground. This flag is only used for device versions after `android.os.Build.VERSION_CODES.O` that requires foreground service to be launched differently. |




