CARP Apps Sampling Package
dk.cachet.carp.apps- a list of installed apps on the phone.
dk.cachet.carp.appusage- a log of app usage activity.
These measures are only available on Android.
For Flutter plugins for other CARP products, see CARP Mobile Sensing in Flutter.
If you're interested in writing you own sampling packages for CARP, see the description on how to extend CARP on the wiki.
To use this package, add the following to you
pubspc.yaml file. Note that
this package only works together with
dependencies: flutter: sdk: flutter carp_core: ^latest carp_mobile_sensing: ^latest carp_apps_package: ^latest ...
Add the following to your app's
AndroidManifest.xml file located in
android/app/src/main such that it contains the following permission request:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<YOUR_PACKAGE_NAME>" xmlns:tools="http://schemas.android.com/tools"> <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> ... </manifest>
Starting with Android 11, Android applications targeting API level 30, wanting to list "external" applications have to declare a new "normal" permission in their
AndroidManifest.xml file called
Permitted use involves apps that must discover any and all installed apps on the device, for awareness or interoperability purposes may have eligibility for the permission. Permitted use includes; device search, antivirus apps, file managers, and browsers.
Apps granted access to this permission must comply with the User Data policies, including the Prominent Disclosure and Consent requirements, and may not extend its use to undisclosed or invalid purposes.
To use this package, import it into your app together with the
import 'package:carp_core/carp_core.dart'; import 'package:carp_mobile_sensing/carp_mobile_sensing.dart'; import 'package:carp_apps_package/apps.dart';
Before creating a study and running it, register this package in the SamplingPackageRegistry.
APP_USAGE measures can be added to a study protocol like this.
// Define which devices are used for data collection // In this case, its only this smartphone Smartphone phone = Smartphone(); protocol.addPrimaryDevice(phone); // Add an automatic task that collects the list of installed apps // and a log of app usage activity protocol.addTaskControl( ImmediateTrigger(), BackgroundTask(measures: [ Measure(type: AppsSamplingPackage.APPS), Measure(type: AppsSamplingPackage.APP_USAGE), ]), phone);
- A library for collecting data from apps on the phone.