activityStream method

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

Requests continuous ActivityEvent updates.

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

On Android, runForegroundService: true starts a foreground service that keeps the updates arriving while the app runs in the background. The app then has to declare the service in its manifest, see the README. 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 = false}) =>
    _stream ??= _createStream(runForegroundService);