Getting Started
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-android-usagestatsmanager`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/android-usagestatsmanager/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치bun add @capgo/capacitor-android-usagestatsmanagerbunx cap syncImport
Importimport { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';API 개요
API 개요 제목queryAndAggregateUsageStats
__CAPGO_KEEP_0__ queryAndAggregateUsageStats__CAPGO_KEEP_0__ 사용량 통계를 지정된 시간 범위에 대해 조회하고 집계합니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000;const now = Date.now();const stats = await UsageStatsManager.queryAndAggregateUsageStats({ beginTime: oneDayAgo, endTime: now});
for (const [packageName, usageData] of Object.entries(stats)) { console.log(`${packageName}: ${usageData.totalTimeInForeground}ms`);}isUsageStatsPermissionGranted
__CAPGO_KEEP_0__ isUsageStatsPermissionGranted__CAPGO_KEEP_0__ 사용량 통계 권한이 부여되었는지 확인합니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
const { granted } = await UsageStatsManager.isUsageStatsPermissionGranted();if (!granted) { await UsageStatsManager.openUsageStatsSettings();}openUsageStatsSettings
__CAPGO_KEEP_0__ openUsageStatsSettings__CAPGO_KEEP_0__ 사용량 통계 설정 화면을 열립니다. 사용자에게 사용량 통계 권한을 부여할 수 있는 사용량 통계 설정 화면을 열립니다. 권한이 이미 부여되어 있더라도 항상 설정 화면을 열립니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
await UsageStatsManager.openUsageStatsSettings();queryAllPackages
__CAPGO_KEEP_0__ queryAllPackages__CAPGO_KEEP_0__를 설치된 모든 패키지를 검색합니다. QUERY_ALL_PACKAGES 권한이 필요합니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
const { packages } = await UsageStatsManager.queryAllPackages();packages.forEach(pkg => { console.log(`${pkg.appName} (${pkg.packageName}): v${pkg.versionName}`);});__CAPGO_KEEP_0__ 참조
__CAPGO_KEEP_0__ 제목: ‘__CAPGO_KEEP_0__ 참조’UsageStatsOptions
__CAPGO_KEEP_0__ 제목: ‘__CAPGO_KEEP_0__ 사용량 통계 옵션’__CAPGO_KEEP_0__ 사용량 통계를 조회하는 옵션입니다.
export interface UsageStatsOptions { /** * The inclusive beginning of the range of stats to include in the results. * Defined in terms of "Unix time" */ beginTime: number;
/** * The exclusive end of the range of stats to include in the results. * Defined in terms of "Unix time" */ endTime: number;}안드로이드 앱의 사용량 통계입니다.
export interface UsageStats { /** * The first timestamp of the usage stats. */ firstTimeStamp: number; /** * The last timestamp of the usage stats. */ lastTimeStamp: number; /** * Only available on Android Q (API level 29) and above. * Will be undefined on lower Android versions. */ lastTimeForegroundServiceUsed?: number; /** * The last time the app was used. */ lastTimeUsed: number; /** * Only available on Android Q (API level 29) and above. * Will be undefined on lower Android versions. */ lastTimeVisible?: number; /** * The name of the package. */ packageName: string; /** * Only available on Android Q (API level 29) and above. * Will be undefined on lower Android versions. */ totalForegroundServiceUsed?: number; /** * The total time the app was in the foreground. */ totalTimeInForeground: number; /** * Only available on Android Q (API level 29) and above. * Will be undefined on lower Android versions. */ totalTimeVisible?: number;}UsageStatsPermissionResult
__CAPGO_KEEP_0__ 제목: ‘__CAPGO_KEEP_0__ 사용량 통계 권한 결과’사용량 통계 권한 결과입니다.
export interface UsageStatsPermissionResult { /** * Whether the usage stats permission is granted. */ granted: boolean;}PackageInfo
패키지 정보설치된 패키지에 대한 기본 정보를 나타냅니다.
export interface PackageInfo { /** Package name */ packageName: string; /** App display name */ appName: string; /** Version name string */ versionName: string; /** Version code number */ versionCode: number; /** First install time in milliseconds since epoch */ firstInstallTime: number; /** Last update time in milliseconds since epoch */ lastUpdateTime: number;}진실의 근원
Section titled “진실의 근원”이 페이지는 플러그인의 src/definitions.ts. upstream에서 API가 변경될 때마다 pubic을 다시 동기화하세요.
Getting Started에서 계속
Section titled “Getting Started에서 계속”Capgo를 사용 중이라면 Getting Started API 대시보드와 운영을 계획하고 연결하세요. Using @capgo/capacitor-android-usagestatsmanager Capacitor의 Native 기능인 Using @capgo/capacitor-android-usagestatsmanager API 개요 Capacitor의 구현 세부 사항인 API 개요 소개 소개의 구현 세부 사항 API 키 API 키의 구현 세부 사항 및 기기 기기의 구현 세부 사항