# Track application lifecycle changes with the native mobile trackers
> Automatically track application foreground and background transitions to understand app usage patterns.
> Source: https://docs.snowplow.io/docs/sources/mobile-trackers/tracking-events/lifecycle-tracking/
> Documentation index: https://docs.snowplow.io/llms.txt

The tracker can capture application lifecycle state changes. In particular, when the app changes state from foreground to background and vice versa.

The lifecycle tracking is enabled by default (since v6.0.0). It can be configured in `TrackerConfiguration` like in the example below:

**iOS:**

```swift
let trackerConfig = TrackerConfiguration()
    .lifecycleAutotracking(true)
```

**Android (Kotlin):**

```kotlin
val trackerConfig = TrackerConfiguration("appId")
    .lifecycleAutotracking(true)
```

**Android (Java):**

```java
TrackerConfiguration trackerConfig = new TrackerConfiguration("appId")
    .lifecycleAutotracking(true);
```

***

Once enabled, the tracker will automatically track a [`Background` event](/docs/events/ootb-data/mobile-lifecycle-events/#background-event) when the app is moved to background and a [`Foreground` event](/docs/events/ootb-data/mobile-lifecycle-events/#foreground-event) when the app moves back to foreground (becomes visible in the screen).

The tracker doesn't track a `Foreground` event when the user launches the app, only when the app returns from the background.

The system can also launch an app in the background, for example for a silent push notification. Events tracked during a background launch report the app as not visible. When the user then opens the app, the trackers behave differently:

- iOS: the tracker doesn't track a `Foreground` event, because it only tracks one after a `Background` event
- Android: the tracker tracks a `Foreground` event

> **Note: Version support**
>
> Lifecycle state on background launches was fixed in version 6.2.6 of the iOS tracker and version 6.4.1 of the Android tracker. iOS tracker version 6.2.6 to 6.3.0 also tracked a `Foreground` event on every launch of a scene-based app, which version 6.3.1 fixed.

The tracker attaches a [`LifecycleEntity`](/docs/events/ootb-data/mobile-lifecycle-events/#lifecycle-entity) to all the events tracked by the tracker reporting if the app was visible (foreground state) when the event was tracked.

The `LifecycleEntity` value is conditioned by the internal state of the tracker only. To make an example, if the app is in foreground state but the developer tracks a `Background` event intentionally, it would force the generation of a `LifecycleEntity` that mark the app as non visible, even if it's actually visible in the device.
