ActivityConfig class

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

Constructors

ActivityConfig({double? activityRecognitionInterval, int? minimumActivityRecognitionConfidence, bool? disableStopDetection, bool? stopOnStationary, int? motionTriggerDelay, String? triggerActivities, bool? disableMotionActivityUpdates, double? stopDetectionDelay})
const
ActivityConfig.fromMap(Map<String, dynamic> m)
factory

Properties

activityRecognitionInterval double?
Controls the sample-rate of the activity-recognition system.
final
disableMotionActivityUpdates bool?
Disable the plugin requesting "Motion & Fitness" (ios) or "Physical Activity" (android >= 10) authorization from the User.
final
disableStopDetection bool?
Disable motion-activity related stop-detection.
final
hashCode int
The hash code for this object.
no setterinherited
minimumActivityRecognitionConfidence int?
The minimum motion-activity confidence to conclude a device is moving.
final
motionTriggerDelay int?
[Android only] Optionally add a delay in milliseconds to trigger Android into the moving state when Motion API reports the device is moving (eg: on_foot, in_vehicle)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stopDetectionDelay double?
[iOS only] Allows the iOS stop-detection system to be delayed from activating.
final
stopOnStationary bool?
Automatically BackgroundGeolocation.stop when the GeoConfig.stopTimeout elapses.
final
triggerActivities String?
Configures a comma-separated list of motion-activities which are allow to trigger location-tracking. ⚠️ Warning: Requires that the user grant your app the "Motion/Health" permission. These are the comma-delimited list of activity-names returned by the ActivityRecognition API which will trigger a state-change from stationary to moving. By default, the plugin will trigger on any of the moving-states:
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, dynamic>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited