__CAPGO_KEEP_2__
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
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.
설치
설치 제목Capgo의 AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. AI 도구에 Capgo 스킬을 추가하려면 다음 명령어를 사용하세요:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins그다음에 다음 프롬프트를 사용하세요:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-android-usagestatsmanager` plugin in my project.만약 Manual Setup을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르시오:
bun add @capgo/capacitor-android-usagestatsmanagerbunx cap syncImport
__CAPGO_KEEP_0__ 개요import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';API Overview
API 시간 범위 내의 사용 통계를 조회하고 집계합니다.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__ 사용 통계 허가 여부를 확인합니다.__CAPGO_KEEP_0__이 사용 통계 권한이 허용되었는지 확인합니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
const { granted } = await UsageStatsManager.isUsageStatsPermissionGranted();if (!granted) { await UsageStatsManager.openUsageStatsSettings();}openUsageStatsSettings
__CAPGO_KEEP_0__ 섹션사용 통계 설정 화면을 열어주세요. 이 버튼을 클릭하면 사용 통계 설정 화면이 열립니다. 사용자에게 사용 통계 권한을 허용하도록 요청합니다. 권한이 이미 허용되어도 항상 설정 화면을 열어줍니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
await UsageStatsManager.openUsageStatsSettings();queryAllPackages
__CAPGO_KEEP_0__ 섹션__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__UsageStatsOptions
__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;}UsageStats
__CAPGO_KEEP_1____CAPGO_KEEP_2__
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_1____CAPGO_KEEP_3__
export interface UsageStatsPermissionResult { /** * Whether the usage stats permission is granted. */ granted: boolean;}PackageInfo
__CAPGO_KEEP_1____CAPGO_KEEP_4__
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;}__CAPGO_KEEP_1__
__CAPGO_KEEP_5__This page is generated from the plugin’s src/definitions.ts업스트림에서 API이 변경될 때 다시 싱크를 실행하세요.
Getting Started에서 계속
Getting Started에서 계속하기Capacitor를 사용하고 있다면 Getting Started Capacitor를 사용하여 대시보드와 API를 계획하고 운영하기 위해서는 @capgo/capacitor-android-usagestatsmanager @capgo/capacitor-android-usagestatsmanager를 사용하는 native capability에 대해 API Overview API Overview에서 구현 세부 정보에 대해 소개 소개에서 구현 세부 정보에 대해 API 키 API 키에서 구현 세부 정보에 대해, 그리고 장치 소개에서 구현 세부 정보에 대해 장치.