开始使用
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-android-kiosk`
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-kiosk/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.
您可以使用我们的 AI 助手设置来安装插件。使用以下命令将 Capgo 技能添加到您的 AI 工具中:
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-kiosk` plugin in my project.如果您prefer Manual Setup,安装插件并运行以下命令,遵循以下平台特定的说明:
bun add @capgo/capacitor-android-kioskbunx cap syncimport { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';API概述
名为“API概述”的部分isInKioskMode
名为“isInKioskMode”检查应用是否当前正在以kiosk模式运行。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isInKioskMode } = await CapacitorAndroidKiosk.isInKioskMode();console.log('Kiosk mode active:', isInKioskMode);isSetAsLauncher
名为“isSetAsLauncher”检查应用是否设置为设备启动器(主应用)。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isLauncher } = await CapacitorAndroidKiosk.isSetAsLauncher();console.log('Is launcher:', isLauncher);enterKioskMode
Section titled “enterKioskMode”进入全屏模式,隐藏系统UI并阻止硬件按钮。 此模式下,应用程序必须被设置为设备启动器,才能有效工作。 此外,应用程序启动前台保活服务,减少系统杀死应用程序的可能性。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.enterKioskMode();exitKioskMode
Section titled “exitKioskMode”退出全屏模式,恢复正常的系统UI和硬件按钮功能。 此外,停止前台保活服务,启动时在enterKioskMode()中启动的服务。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.exitKioskMode();console.log('Exited kiosk mode');setAsLauncher
Section titled “setAsLauncher”打开设备的主屏幕设置,允许用户将此应用程序设置为启动器。 此功能是全屏模式的必备条件。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.setAsLauncher();// User will be prompted to select this app as the home appsetAllowedKeys
Section titled “setAllowedKeys”设置在全屏模式下允许功能的硬件键。 默认情况下,全屏模式下所有硬件键都被阻止。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
// Allow volume keys onlyawait CapacitorAndroidKiosk.setAllowedKeys({ volumeUp: true, volumeDown: true, back: false, home: false, recent: false});类型参考
类型参考EnterKioskModeOptions
进入全屏模式选项全屏模式下允许的可选标志 enterKioskMode.
export interface EnterKioskModeOptions { /** * After reboot, start the app so you can call `enterKioskMode()` again. Best-effort only (OEM * behavior, force-stop). Omit to keep the saved value. Cleared when you call `exitKioskMode()`. */ restoreAfterReboot?: boolean;
/** * Periodically tries to bring the app to the foreground. Skipped while the screen is off. Often * blocked from the background on some devices—being the default launcher, relaxing battery limits, * and allowing exact alarms (where required) improve odds. Omit to keep the saved value. */ relaunch?: boolean;
/** Minutes between relaunch attempts when `relaunch` is on. Range 5–60; default 15. */ relaunchIntervalMinutes?: number;}AllowedKeysOptions
允许的硬件键配置选项复制到剪贴板
export interface AllowedKeysOptions { /** * Allow volume up button * @default false */ volumeUp?: boolean;
/** * Allow volume down button * @default false */ volumeDown?: boolean;
/** * Allow back button * @default false */ back?: boolean;
/** * Allow home button * @default false */ home?: boolean;
/** * Allow recent apps button * @default false */ recent?: boolean;
/** * Allow power button * @default false */ power?: boolean;
/** * Allow camera button (if present) * @default false */ camera?: boolean;
/** * Allow menu button (if present) * @default false */ menu?: boolean;}重新同步公共__CAPGO_KEEP_0__时请重新运行。 src/definitions.ts重新同步公共API时请重新运行。
继续从 Getting Started
标题:继续从 Getting Started如果您正在使用 Getting Started 来规划仪表板和API操作,连接它与 使用@capgo/capacitor-android-kiosk 对于在使用@capgo/capacitor-android-kiosk中的本机功能 API概述 对于API概述中的实现细节 介绍 对于介绍中的实现细节 API密钥 对于在API Keys中实现的详细信息,并且 设备 对于在设备中实现的详细信息。