Cordova Background Location - How i can get activity (walk, run,...) from the plugin for save it in location object?

My Environment

  • Plugin version: 2.2.5
  • Platform: iOS & Android
  • OS version: iOS 10.3.2 / Android 7.0
  • Device manufacturer and model: iPhone 5S / Galaxy S6 edge
  • Cordova version (cordova -v): 7.0.1
  • Cordova platform version (cordova platform ls): ios 4.4.0 / android 6.2.3
  • Plugin configuration options:
// Background Tracking
		let config = {
			// Both (Android & iOS)  
			desiredAccuracy            : 10,
			stationaryRadius           : 50, // Stationary radius in meters. When stopped, the minimum distance the device must move beyond the stationary location for aggressive background-tracking to engage.
			distanceFilter             : 30, // The minimum distance (measured in meters) a device must move horizontally before an update event is generated. @see Apple docs.
			debug                      : true, //  enable this hear sounds for background-geolocation life-cycle.
			stopOnTerminate            : false, // enable this to clear background location settings when the app terminates
			startOnBoot                : false, // Start background service on device boot. (default false)
			notificationTitle          : 'Background tracking',
			geofenceProximityRadius    : 1000,
			triggerActivities          : 'on_foot, walking, running, on_bicycle, in_vehicle, still',
			// maxLocations            : 10000 // Limit maximum number of locations stored into db (default: 10000)
			// Only for Android (Detect activity for Android)
			locationProvider           : this.backgroundGeolocation.LocationProvider.ANDROID_ACTIVITY_PROVIDER,
			interval                   : 10000, // Rate in milliseconds at which your app prefers to receive location updates. @see android docs
			fastestInterval            : 5000, // Fastest rate in milliseconds at which your app can handle location updates. @see android docs.
			activitiesInterval         : 300000, // Rate in milliseconds at which activity recognition occurs. Larger values will result in fewer activity detections while improving battery life.
			stopOnStillActivity        : true, // stop() is forced, when the STILL activity is detected (default is true)
			// Only for iOS (Detect activity for iOS)
			activityType               : 'AutomotiveNavigation',
			activityRecognitionInterval: 5000,
			stopTimeout                : 5,
			locationAuthorizationAlert: {
				titleWhenNotEnabled: "Yo, location-services not enabled",
				titleWhenOff       : "Yo, location-services OFF",
				instructions       : "You must enable 'Always' in location-services, buddy",
				cancelButton       : "Cancel",
				settingsButton     : "Settings"


When i try to detect the device activity, an alert show the coordinates and the activity but i want catch the activity type for link it in my location object.

like that:

var currentPosition  = {
				'latitude'           : position.latitude,
				'longitude'          : position.longitude,
				'altitude'           : null,
				'accuracy'           : position.accuracy,
				'altitude_accuracy'  : null,
				'heading'            : null,
				'speed'              : null,
				'timestamp'          : position.time,
				'activity'           : position.activity.type || null,
				'activity_confidence': position.activity.confidence || null

If someone can help me ? Thanks a lot =)

Is this alert presented by your application, or by some external agent?

I think it’s from de native code android/ios.

But i have find my solution ! I used an older fork of the plugin instead of the last version of cordova-background-geolocation-lt.

Thanks rapropos for your help !

Hi, can you detail on this? I’m also trying to get the altitude on android, and so far, everything that I tried returned null for altitude.

Please share the older repo url