activityStream method

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

Requests continuous ActivityEvent updates.

The Stream will output the most probable ActivityEvent. By default the foreground service is enabled, which allows the updates to be streamed while the app runs in the background. The programmer can choose to not enable to foreground service.

Implementation

Stream<ActivityEvent> activityStream({bool runForegroundService = true}) {
  if (_stream == null) {
    _stream = _eventChannel
        .receiveBroadcastStream({"foreground": runForegroundService}).map(
            (json) => ActivityEvent.fromString(json));
  }
  return _stream!;
}