시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
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 보조 설치를 사용하여 플러그인을 설치할 수 있습니다. 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
Importimport { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';API 개요
API 개요queryAndAggregateUsageStats
사용 통계 쿼리 및 집계복사
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
복사사용 통계 설정 열기
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
이것은 사용 통계 설정 화면을 열어 주며, 사용자가 사용 통계 허용을 허용하도록 합니다.이것은 항상 설정 화면을 열어 주며, 허용이 이미 허용되어도 됩니다.
import { CapacitorUsageStatsManager } from '@capgo/capacitor-android-usagestatsmanager';
const { packages } = await UsageStatsManager.queryAllPackages();packages.forEach(pkg => { console.log(`${pkg.appName} (${pkg.packageName}): v${pkg.versionName}`);});queryAllPackages 섹션
모든 설치된 패키지를 기기에서 조회합니다. QUERY_ALL_PACKAGES 허용이 필요합니다.UsageStatsOptions
클립보드 복사타입 참조
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
사용 통계 옵션사용 통계 옵션 섹션입니다. 사용 통계를 조회하는 데 사용됩니다.
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
사용자 통계 권한 결과사용자 통계 권한 확인 결과입니다.
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;}실질적 출처
실질적 출처이 페이지는 플러그인의 src/definitions.ts. Re-run the sync when the public API changes upstream.
Getting Started에서 계속하세요
Section titled “Getting Started를 계속하기”만약 당신이 사용 중이라면 Getting Started 계획 대시보드와 API 연산을 위해 capgo와 capacitor-android-usagestatsmanager를 연결하세요 capgo를 사용하여 native 기능을 위해 @capgo/capacitor-android-usagestatsmanager API 개요 API 구현 세부사항을 위해 소개 소개 구현 세부사항을 위해 API 키 API 키 구현 세부사항을 위해 기기 기기 구현 세부 사항에 대한 자세한 내용입니다.