Apps Sampling Package
Collect the installed apps and per-app usage time from Android phones in a CARP Mobile Sensing study.
carp_apps_package adds two measures to a CARP Mobile Sensing (CAMS) study: the installed apps and how long each app was in the foreground. Use them when a study looks at how participants use their phone.
The package reads the app list with the installed_apps plugin and the usage times from Android's usage statistics with the app_usage plugin.
Android only
Both measures work on Android only. On iOS, CAMS skips them and logs a warning, so a protocol that contains them still runs on iOS, without app data.
Features
Installed apps
Lists the non-system apps that the participant can open from the launcher, with package name, version and last update time.
App usage
Records how long each app was in the foreground over a time window, from Android's usage statistics.
Measure types
The package has two one-time measure types, which collect once each time their trigger fires:
| Measure type | Data | Android | iOS |
|---|---|---|---|
dk.cachet.carp.apps | Installed apps that have a launcher entry, without system apps | Yes | No |
dk.cachet.carp.appusage | Foreground time per app over a time window | Yes | No |
For the measure types of the other sampling packages, see Measure types.
Requirements
| Component | Requirement |
|---|---|
| Dart SDK | 3.10 or later, the CAMS minimum |
| Flutter | 3.38.1 or later, the CAMS minimum |
carp_mobile_sensing | 2.2.0 or later |
| Android | API level 24 (Android 7.0) or later, the CAMS minimum |
| iOS | Not supported |
How it works
Adding the package to a study takes three steps:
Register the package
Registering an
AppsSamplingPackagein theSamplingPackageRegistrymakes the two measure types and their data classes known to CAMS.Add the measures with a repeating trigger
One-time measures collect only when their trigger fires, so use a trigger that repeats, such as a
PeriodicTrigger. App usage also needs its ownHistoricSamplingConfiguration, so that each collection continues where the previous one ended, also after an app restart.Deploy and grant usage access
After you deploy the protocol, CAMS collects both measures each time the trigger fires. For app usage, the participant must also turn on Usage access for the app in Android settings. The
app_usageplugin opens that screen when access is missing.
This example registers the package and collects both measures once a day:
Next steps
Installation
Add the package and the Android manifest entries.
Quickstart
Build an app that collects both measures and prints them.
Installed apps
The apps installed on an Android phone, with version and update time.
App usage
Foreground time per app over a time window, from Android usage statistics.