carp_apps_package 0.11.1 carp_apps_package: ^0.11.1 copied to clipboard
Apps sampling package for the CARP Mobile Sensing framework (Android only).
import 'package:carp_apps_package/apps.dart';
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';
/// This is a very simple example of how this sampling package is used with CARP Mobile Sensing (CAMS).
/// NOTE, however, that the code below will not run.
/// See the documentation on how to use CAMS: https://github.com/cph-cachet/carp.sensing-flutter/wiki
void main() async {
SamplingPackageRegistry().register(AppsSamplingPackage());
Study study = Study(id: "1234", userId: "xyz", name: "apps study");
// creating a task collecting a list of installed apps and app usage
study.addTriggerTask(
ImmediateTrigger(), // a simple trigger that starts immediately
Task(name: 'Step and blood pressure')
..addMeasure(
Measure(
type: MeasureType(NameSpace.CARP, AppsSamplingPackage.APP_USAGE),
name: 'App usage',
),
)
..addMeasure(
Measure(
type: MeasureType(NameSpace.CARP, AppsSamplingPackage.APPS),
name: 'Installed apps',
),
));
// Create a Study Controller that can manage this study, initialize it, and start it.
StudyController controller = StudyController(study);
// await initialization before starting
await controller.initialize();
controller.resume();
// listening on all data events from the study
controller.events.forEach(print);
}