activity property

ActivityConfig? activity
final

Activity Recognition Configuration.

The ActivityConfig object defines options related to motion and activity detection for the BackgroundGeolocation SDK. These parameters control how the SDK interprets transitions between moving and stationary states using platform motion APIs (Android Activity Recognition / iOS Core Motion).

Overview

ActivityConfig is consumed via the Config.activity property when calling BackgroundGeolocation.ready or BackgroundGeolocation.setConfig.

Category Description
Motion Detection Tune recognition cadence and sensitivity via ActivityConfig.activityRecognitionInterval (Android) and ActivityConfig.minimumActivityRecognitionConfidence (Android).
Behavioral Options Control moving↔stationary transitions with ActivityConfig.disableStopDetection (cross-platform behavioral), ActivityConfig.stopOnStationary (cross-platform behavioral), and ActivityConfig.motionTriggerDelay (Android).
Motion Updates Toggle Enable/disable motion activity updates with ActivityConfig.disableMotionActivityUpdates (Android & iOS).
iOS Timing Fine-tune stop detection timing with ActivityConfig.stopDetectionDelay (iOS).

Example

import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;

void main() async {
  final config = bg.Config(
    activity: bg.ActivityConfig(
      // Android: poll activity recognition every 10s
      activityRecognitionInterval: 10000,

      // Android: require ≥75% confidence to change activity
      minimumActivityRecognitionConfidence: 75,

      // Cross-platform behavioral: keep or disable auto stop detection
      disableStopDetection: false,

      // Cross-platform behavioral: automatically stop when stationary
      stopOnStationary: true,

      // Android: delay motion-trigger transitions by 30s
      motionTriggerDelay: 30000,

      // Android & iOS: disable platform motion updates entirely
      disableMotionActivityUpdates: false,

      // iOS: delay stop-detection by 10s
      stopDetectionDelay: 10000,
    ),
  );

  await bg.BackgroundGeolocation.ready(config);
}

Migrating from legacy Config

In earlier versions of the plugin, motion and activity parameters were defined directly in the root Config object, such as:

BackgroundGeolocation.ready(Config(
  activityRecognitionInterval: 10000,
  disableStopDetection: true,
  stopOnStationary: true,
));

These have now been grouped under ActivityConfig:

BackgroundGeolocation.ready(Config(
  activity: ActivityConfig(
    activityRecognitionInterval: 10000,
    disableStopDetection: true,
    stopOnStationary: true,
  )
));

This refactor provides a clearer separation of responsibilities and aligns with other configuration groups such as GeoConfig, HttpConfig, and AppConfig.

See also

Implementation

final ActivityConfig? activity;