开始入门
复制一个包含安装步骤和此插件的完整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 sync导入
导入import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';API概述
API概述isInKioskMode
是否处于全屏模式复制到剪贴板
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isInKioskMode } = await CapacitorAndroidKiosk.isInKioskMode();console.log('Kiosk mode active:', isInKioskMode);isSetAsLauncher
复制到剪贴板是否设置为启动器(主应用)
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isLauncher } = await CapacitorAndroidKiosk.isSetAsLauncher();console.log('Is launcher:', isLauncher);enterKioskMode
进入全屏模式进入全屏模式,隐藏系统UI并阻止硬件按钮。 此外,启动前台保活服务,使应用程序更不容易被系统杀死。 此功能需要将应用程序设置为设备启动器才能有效工作。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.enterKioskMode();exitKioskMode
标题:exitKioskMode退出全屏模式,恢复正常的系统UI和硬件按钮功能。 此外,停止前台保活服务,启动时enterKioskMode()中启动的。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.exitKioskMode();console.log('Exited kiosk mode');setAsLauncher
标题:setAsLauncher打开设备的主屏幕设置,允许用户将此应用程序设置为启动器。 此功能是全屏模式功能的必要条件。
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.setAsLauncher();// User will be prompted to select this app as the home appsetAllowedKeys
标题: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;}真实数据来源
真实数据来源此页面是根据插件的 src/definitions.ts当公共API在上游发生变化时,请重新运行同步。
继续从开始使用
Section titled “从开始就继续”如果您正在使用 开始 来规划仪表板和API操作,连接它与 使用@capgo/capacitor-android-kiosk 为native能力在使用@capgo/capacitor-android-kiosk, API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节和 设备 关于设备的实现细节.