慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

L
LangChain Blog
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
J
Java Code Geeks
Recent Announcements
Recent Announcements
The Cloudflare Blog
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
Vercel News
Vercel News
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
雷峰网
雷峰网
H
Help Net Security
博客园 - Franky
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
博客园_首页
C
Check Point Blog
腾讯CDC
美团技术团队
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
U
Unit 42
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Engineering at Meta
Engineering at Meta
M
Microsoft Research Blog - Microsoft Research
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
B
Blog
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
H
Hackread – Cybersecurity News, Data Breaches, AI and More
李成银的技术随笔
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Optic is dead. A 2026 migration guide for OpenAPI breaking changes Smart Blind Stick, Mini Project The NSA just published an MCP security playbook. We created Agent Trust Transport Protocol ATTP - Implement today with MCPS Symfony 8 AWS Secrets Bundle What RepoSignal Surfaced in React — and Why Review Alone Doesn't Catch Everything LeetCode Solution: 1752. Check if Array Is Sorted and Rotated Breaking the Matrix at 15: How I Built a Cyber-Aesthetic AI Assistant Core Powered by Gemma 4 No More Manual Test Writing: How I Used Gemma 4 to Turn a GitHub Repo Into a Full Test Suite 🎯 Trafik Cezaları Platformları Geliştirirken Öğrendiğim Teknik Dersler The Myth of Low Latency: Why Event Meshes Make Your System Slow Building EIDOLON OS — A Local-First AI Cognitive Operating System qrrot - database with AI I Built a Local Gemma 4 Reviewer for Merchant Registry Evidence Compass v1.1.0 · we shipped a memory plugin that catches its own consumption drift How to build your first MCP server in 10 minutes Expo SDK 56 Is Out, and a Few Things Finally Clicked Into Place Building a 100ms Browser-Native WebSocket Clipboard Cómo solucionar `docker run` con `Exited (1)` en Raspberry Pi Why Claude Code Sessions Diverge: A Mechanism Catalog When One AI Agent Is Not Enough: A Practical Delegation Pattern for Enterprise Systems Cómo solucionar el bucle infinito en `useEffect` con objetos y arrays 🛢️ The Dangote Chain: What a Blockchain-Native Refinery IPO Would Look Like Build a "Where to Watch" feature in 50 lines with the StreamWatchHub API Gemma 4 on Android: Tricks for Faster On-Device Inference Your AI agent has amnesia. You've just normalized it. 🚀 Reviving My Women Safety System – From Idea to Real-Time Smart Safety Solution I built an AI that reviews every PR automatically (because nobody was reviewing mine) 🌿 Git Mastery: The Complete Developer Guide Bringing Gemma 4 E2B to the Edge: Building a Privacy-First Dream Analyzer with Flutter & LiteRT Google I/O 2026 Wasn’t About Features — It Was About AI Becoming the Developer Environment Building an AI Vedic Astrology App in 25 Days — What Actually Worked (and What Didn't) Hermes Agent Has Four Memories — And That's Why It Doesn't Forget You Pressure Isn't Killing You -Your Relationship With It Is 🐳 How to Run Any Project in Docker: A Complete Guide AccessLens — a blind person's lanyard, powered by Gemma 4 on-device Glyph v0.2: the release is the joinery How I Built a Blazingly Fast, Privacy-First Batch Image Converter in the Browser Using OPFS and Web Workers Cómo solucionar \"Text content does not match server-rendered HTML\" en Next.js App Router FCoP 3.0: Why AI Agents Need a Track, Not a Brake Fibonacci: Quiz app which anyone can make revenue by viewing ads to the quiz contestants. The Subconscious Powered by Edge AI GPU Utilization Is Becoming the New Cloud Waste Crisis Cómo solucionar `docker run` con exit code 1 en Raspberry Pi JWT is a scam and your app doesn't need it 7 Agent Skill Packs That Actually Make AI Coders Better More Control, More Cost: Why Commanding AI Isn't Delegation SecureScan Synthadoc: We Built an AI Judge for Our AI Wiki Compiler - Here's What We Learned Cómo solucionar el error de permiso al ejecutar `pip.exe` en entorno virtual (Python 3.10 en Windows) Postgres-grade Serializable at 20k+ ops/s — on a laptop. Don’t try this at home.
Android Kiosk 应用开发
Davran Khasa · 2026-05-24 · via DEV Community

诸君安好,此乃吾初度著文。亦初试撰文之事。

今且略叙己志。
吾名Давран,乃安卓匠人也,八载研习,制诸般掌中器。

吾之履历:

今朝,吾欲以安卓机柜为题,开吾之述怀。

初见,安卓之亭台应用,似简:但求将客囚于屏之一隅。

然实践之,事颇繁复。

吾于Pai之项目,既营平板之应用,复撰启动器(虽后知非启动器也)。

*亭台者何?
亭台应用者,此乃限权之应用,用户不得越出此应用之外.

此等方案,多用于终端、POS系统、信息亭及自助服务之设备.

其要求

初期,所求似简,吾有少许撰作安卓启动器之验,遂以为此识及若干GitHub上之小试足矣解此题。
然吾心中多惑,遂引吾求此域之文牍(链接__JHSNS_SEG_f8fbe380_17__)

总之所需者:

  • 用户不能出应用
  • 应用须随设备启动而自启
  • 不可授系统设置与界面之权

实现之方

所需者,惟些许文牍,数段代码而已

所本之策,乃Device Owner与Lock Task Mode也

既而,当入于代码之实矣...

售货机控制器

首事,当习设备策略管理器API
简言之,此乃设备管理员之API,使吾辈得行诸事(如管理应用、管理设备之设置等)
然为此,吾辈需二者之一,或得所需权限,或具管理员之权柄(此非设备之越狱也)

继而,吾辈当习知KeyguardManager API
此API,吾辈用以操弄设备之锁屏,尤以监听其状态为要

且,吾辈亦需立DeviceAdminReceiver 以获取吾等应用之既设配置

1 - 吾辈需立应用白名单,俾其得以于自助模式运行,故当构制包名数组:

private val WHITE_LIST_PACKAGES = arrayOf(
    "your.package.name",
    "dev.firebase.appdistribution",
    "com.android.settings"
)

Enter fullscreen mode Exit fullscreen mode

2 - 吾辈构制 KioskController 之典,并立系服务之引

 private val dpm = context.getSystemService(DevicePolicyManager::class.java)
    private val keyguard = context.getSystemService(KeyguardManager::class.java)
    private val admin = ComponentName(context, AdminReceiver::class.java)

Enter fullscreen mode 退出全屏模式

3 - 主要工作将由我们DevicePolicyManager完成
而第一行魔法代码是

dpm.setLockTaskPackages(admin, arrayOf(WHITE_LIST_PACKAGES))

进入全屏模式 退出全屏模式

此命令向系统发送白名单应用列表,可在自助服务模式下打开

第二行魔法代码

dpm.setLockTaskFeatures(
admin,
DevicePolicyManager.LOCK_TASK_FEATURE_NONE
)

进入全屏模式 退出全屏模式

此命令将关闭所有在自助模式下设置的UI元素(状态栏、导航栏,简言之,在自助模式下,系统所有外部UI均被关闭)

我所发现的唯一缺点是新API的曲折,因标志
DevicePolicyManager.LOCK_TASK_FEATURE_NONE将关闭所有
然无全选之旗,故须合用诸旗,方得返于自助模式

dpm.setLockTaskFeatures(
            admin,
            DevicePolicyManager.LOCK_TASK_FEATURE_HOME or
                DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW or
                DevicePolicyManager.LOCK_TASK_FEATURE_NOTIFICATIONS or
                DevicePolicyManager.LOCK_TASK_FEATURE_GLOBAL_ACTIONS
        )

Enter fullscreen mode Exit fullscreen mode

及至出口,得二函数

 fun enterAdminMode() {
        if (!isDeviceOwner()) return
        dpm.setLockTaskFeatures(
            admin,
            DevicePolicyManager.LOCK_TASK_FEATURE_HOME or
                DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW or
                DevicePolicyManager.LOCK_TASK_FEATURE_NOTIFICATIONS or
                DevicePolicyManager.LOCK_TASK_FEATURE_GLOBAL_ACTIONS
        )
    }

Enter fullscreen mode Exit fullscreen mode

fun exitAdminMode() {
        if (!isDeviceOwner()) return

        dpm.setLockTaskFeatures(admin, DevicePolicyManager.LOCK_TASK_FEATURE_NONE)
    }

Enter fullscreen mode Exit fullscreen mode

尚有辅助

fun canStartLockTask(): Boolean {
        if (!isDeviceOwner()) return false
        if (!dpm.isLockTaskPermitted(context.packageName)) return false
        return !keyguard.isDeviceLocked
    }

Enter fullscreen mode Exit fullscreen mode

isLockTaskPermitted__——此乃验应用得入机柜之权

fun isDeviceOwner(): Boolean = dpm.isDeviceOwnerApp(context.packageName)

Enter fullscreen mode Exit fullscreen mode

验设备管理员之权

DevicePolicyManager亦具添制限之能
者,可令器物有开关之能:

  • 此为保险箱
  • 重置出厂设置
  • 连接外置USB
  • 添设账户于器上
  • 蓝牙之设

复有他事多多。__JHSNS_SEG_f8fbe380_77__变量admin者,即DeviceAdminReceiver也。
者,助系统辨明诸此设定之施行处也。

*安装应用

控制器之设既成,当复将设备归诸出厂之态,启USB调试,许以USB安装,且勿于设备上立帐亦勿认帐。

吾置吾之應用於設備,啟終端,執行命命。

設置設備擁有者

adb shell dpm set-device-owner "your.package.name/com.example.AdminReceiver

入全景模式 出全屏模式

移除设备主人

adb shell dpm remove-active-admin "your.package.name/com.example.AdminReceiver

入全景模式 出全屏模式

吾等当指明吾等之AdminReceiver(此乃吾等于KioskController中所创之DeviceAdminReceiver)之路径

class AdminReceiver : DeviceAdminReceiver()

Enter fullscreen mode Exit fullscreen mode

于此,吾等所余者,惟将吾等之应用设为设备之主屏启动器耳,且贺君,君今为设备之主于机柜模式矣。

P.S - 吾以 SingleActivity 之架构,增一隐秘之键,俾启 AdminScreen。
输入管理员密码,脱出平板配置之模式。

若尔欲闻其详,吾可细述之。