{"id":28489612,"url":"https://github.com/cap-go/capacitor-android-usagestatsmanager","last_synced_at":"2026-05-04T09:04:20.820Z","repository":{"id":286729790,"uuid":"962336539","full_name":"Cap-go/capacitor-android-usagestatsmanager","owner":"Cap-go","description":"Capacitor plugin to get Android app usage stats natively","archived":false,"fork":false,"pushed_at":"2026-04-20T12:42:21.000Z","size":886,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-20T13:51:00.871Z","etag":null,"topics":["capacitor","ionic","plugin"],"latest_commit_sha":null,"homepage":"https://capgo.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-04-08T02:22:46.000Z","updated_at":"2026-04-20T11:33:15.000Z","dependencies_parsed_at":"2025-08-03T00:36:40.259Z","dependency_job_id":null,"html_url":"https://github.com/Cap-go/capacitor-android-usagestatsmanager","commit_stats":null,"previous_names":["cap-go/capacitor-android-usagestatsmanager"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-android-usagestatsmanager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-android-usagestatsmanager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32600968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capacitor","ionic","plugin"],"created_at":"2025-06-08T06:37:15.602Z","updated_at":"2026-05-04T09:04:20.813Z","avatar_url":"https://github.com/Cap-go.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":[],"sub_categories":[],"readme":"# @capgo/capacitor-android-usagestatsmanager\n \u003ca href=\"https://capgo.app/\"\u003e\u003cimg src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/\u003e\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/?ref=plugin_android_usagestatsmanager\"\u003e ➡️ Get Instant updates for your App with Capgo\u003c/a\u003e\u003c/h2\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/consulting/?ref=plugin_android_usagestatsmanager\"\u003e Missing a feature? We’ll build the plugin for you 💪\u003c/a\u003e\u003c/h2\u003e\n\u003c/div\u003e\n\n## Description\nExposes the Android's UsageStatsManager SDK to Capacitor\n\n## Why Android UsageStatsManager?\n\nThe only plugin exposing Android's **UsageStatsManager API** to Capacitor - this Android API was not supported by any plugin before:\n\n- **App usage tracking** - Monitor which apps users open and for how long\n- **Screen time analytics** - Build parental controls and digital wellbeing features\n- **Package information** - Query all installed apps on the device\n- **Time-based queries** - Get usage stats for any time range\n\nPerfect for parental control apps, digital wellbeing tools, productivity trackers, and screen time managers.\n\n## Usage\n\nRequires the following permissions in your `AndroidManifest.xml`:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.PACKAGE_USAGE_STATS\"\n    tools:ignore=\"ProtectedPermissions\" /\u003e\n\u003cuses-permission android:name=\"android.permission.QUERY_ALL_PACKAGES\"\n    tools:ignore=\"QueryAllPackagesPermission\" /\u003e\n```\n\n\n\n## Documentation\n\nThe most complete doc is available here: https://capgo.app/docs/plugins/android-usagestatsmanager/\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-android-usagestatsmanager\nnpx cap sync\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`queryAndAggregateUsageStats(...)`](#queryandaggregateusagestats)\n* [`isUsageStatsPermissionGranted()`](#isusagestatspermissiongranted)\n* [`openUsageStatsSettings()`](#openusagestatssettings)\n* [`queryAllPackages()`](#queryallpackages)\n* [`getPluginVersion()`](#getpluginversion)\n* [Interfaces](#interfaces)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\nCapacitor plugin for accessing Android UsageStatsManager API.\n\n### queryAndAggregateUsageStats(...)\n\n```typescript\nqueryAndAggregateUsageStats(options: UsageStatsOptions) =\u003e Promise\u003cRecord\u003cstring, UsageStats\u003e\u003e\n```\n\nQueries and aggregates usage stats for the given time range.\n\n| Param         | Type                                                            | Description                            |\n| ------------- | --------------------------------------------------------------- | -------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#usagestatsoptions\"\u003eUsageStatsOptions\u003c/a\u003e\u003c/code\u003e | - The time range options for the query |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#record\"\u003eRecord\u003c/a\u003e\u0026lt;string, \u003ca href=\"#usagestats\"\u003eUsageStats\u003c/a\u003e\u0026gt;\u0026gt;\u003c/code\u003e\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### isUsageStatsPermissionGranted()\n\n```typescript\nisUsageStatsPermissionGranted() =\u003e Promise\u003cUsageStatsPermissionResult\u003e\n```\n\nChecks if the usage stats permission is granted.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#usagestatspermissionresult\"\u003eUsageStatsPermissionResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### openUsageStatsSettings()\n\n```typescript\nopenUsageStatsSettings() =\u003e Promise\u003cvoid\u003e\n```\n\nOpen the usage stats settings screen.\nThis will open the usage stats settings screen, which allows the user to grant the usage stats permission.\nThis will always open the settings screen, even if the permission is already granted.\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### queryAllPackages()\n\n```typescript\nqueryAllPackages() =\u003e Promise\u003c{ packages: PackageInfo[]; }\u003e\n```\n\nQueries all installed packages on the device.\nRequires the QUERY_ALL_PACKAGES permission.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ packages: PackageInfo[]; }\u0026gt;\u003c/code\u003e\n\n**Since:** 1.2.0\n\n--------------------\n\n\n### getPluginVersion()\n\n```typescript\ngetPluginVersion() =\u003e Promise\u003c{ version: string; }\u003e\n```\n\nGet the native Capacitor plugin version.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ version: string; }\u0026gt;\u003c/code\u003e\n\n**Since:** 1.0.0\n\n--------------------\n\n\n### Interfaces\n\n\n#### UsageStats\n\nUsage statistics for an Android app.\n\n| Prop                                | Type                | Description                                                                                        |\n| ----------------------------------- | ------------------- | -------------------------------------------------------------------------------------------------- |\n| **`firstTimeStamp`**                | \u003ccode\u003enumber\u003c/code\u003e | The first timestamp of the usage stats.                                                            |\n| **`lastTimeStamp`**                 | \u003ccode\u003enumber\u003c/code\u003e | The last timestamp of the usage stats.                                                             |\n| **`lastTimeForegroundServiceUsed`** | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`lastTimeUsed`**                  | \u003ccode\u003enumber\u003c/code\u003e | The last time the app was used.                                                                    |\n| **`lastTimeVisible`**               | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`packageName`**                   | \u003ccode\u003estring\u003c/code\u003e | The name of the package.                                                                           |\n| **`totalForegroundServiceUsed`**    | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`totalTimeInForeground`**         | \u003ccode\u003enumber\u003c/code\u003e | The total time the app was in the foreground.                                                      |\n| **`totalTimeVisible`**              | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n\n\n#### UsageStatsOptions\n\nOptions for querying usage statistics.\n\n| Prop            | Type                | Description                                                                                              |\n| --------------- | ------------------- | -------------------------------------------------------------------------------------------------------- |\n| **`beginTime`** | \u003ccode\u003enumber\u003c/code\u003e | The inclusive beginning of the range of stats to include in the results. Defined in terms of \"Unix time\" |\n| **`endTime`**   | \u003ccode\u003enumber\u003c/code\u003e | The exclusive end of the range of stats to include in the results. Defined in terms of \"Unix time\"       |\n\n\n#### UsageStatsPermissionResult\n\nResult of a usage stats permission check.\n\n| Prop          | Type                 | Description                                    |\n| ------------- | -------------------- | ---------------------------------------------- |\n| **`granted`** | \u003ccode\u003eboolean\u003c/code\u003e | Whether the usage stats permission is granted. |\n\n\n#### PackageInfo\n\nRepresents basic information about an installed package.\n\n| Prop                   | Type                | Description                                    |\n| ---------------------- | ------------------- | ---------------------------------------------- |\n| **`packageName`**      | \u003ccode\u003estring\u003c/code\u003e | Package name                                   |\n| **`appName`**          | \u003ccode\u003estring\u003c/code\u003e | App display name                               |\n| **`versionName`**      | \u003ccode\u003estring\u003c/code\u003e | Version name string                            |\n| **`versionCode`**      | \u003ccode\u003enumber\u003c/code\u003e | Version code number                            |\n| **`firstInstallTime`** | \u003ccode\u003enumber\u003c/code\u003e | First install time in milliseconds since epoch |\n| **`lastUpdateTime`**   | \u003ccode\u003enumber\u003c/code\u003e | Last update time in milliseconds since epoch   |\n\n\n### Type Aliases\n\n\n#### Record\n\nConstruct a type with a set of properties K of type T\n\n\u003ccode\u003e{\r [P in K]: T;\r }\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-android-usagestatsmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-go%2Fcapacitor-android-usagestatsmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-android-usagestatsmanager/lists"}