activityStream method

Stream<ActivityEvent> activityStream({
  1. bool runForegroundService = true,
})

Requests continuous ActivityEvent updates.

The stream emits the most probable ActivityEvent detected by the phone.

On Android a foreground service is started by default, which allows the updates to keep arriving while the app runs in the background. Pass runForegroundService: false to opt out. The flag is ignored on iOS, where updates are delivered in the background regardless.

The returned stream is a broadcast stream and is built once; later calls return the same stream and do not re-apply runForegroundService.

Implementation

Stream<ActivityEvent> activityStream({bool runForegroundService = true}) =>
    _stream ??= _createStream(runForegroundService);