Android 中的 Kiosk 模式
我正在评估是否以及如何将 CF .NET 企业应用程序移植到 Android 设备上运行。 Windows Mobile 手机上的应用程序以信息亭模式运行,应用程序在启动后以全屏模式自动启动,并且用户无法意外或自愿访问手机的任何其他部分。
Android 上是否可以在启动后仅自动启动一个应用程序,并防止用户意外(或故意)访问 Android 设备的任何其他部分?
I'm in the process of evaluating if and how a CF .NET enterprise application can be ported to run on Android devices. The application on Windows Mobile phones are run in kiosk mode where the application autostart in fullscreen-mode after booting and with the users unable to accidentally or willingly access any other parts of the phone.
Is it possible on Android to have only one application autostart after booting and prevent users from accidentally (or willingly) access any other parts of the Android device?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
您可以通过监听 BroadcastReceiver 中的
android.intent.action.BOOT_COMPLETED
Intent 在启动时自动启动应用程序,并从那里启动您的 Activity。在活动中,您可以将自己注册为新的默认主屏幕[1]并处理按键。我认为在某些情况下,如果不修改框架就无法处理(例如长按主页以显示当前活动的应用程序) - 但我也可能是错误的。
但对于原型来说这可能就足够了。
玩得开心修补!
[1]:
You can autostart applications on boot by listening to the
android.intent.action.BOOT_COMPLETED
intent in a BroadcastReceiver and start your Activity from there. In the Activity you can register yourself as the new default homescreen[1] and handle the keys.I think there are some instances that you can't handle without modifying the framework (like longpress on Home to show currently active Applications) - I could also be mistaken though.
But for a prototype that could be sufficient.
Have fun tinkering!
[1]:
您可以对此进行自定义(禁用对菜单的访问、限制应用程序添加等)以启用信息亭。 http://code.google.com/p/android-launcher-plus/
You could customise this (disable access to menu, limit application addition etc) to enable kiosk. http://code.google.com/p/android-launcher-plus/
在新的 Android L 预览版中,Google 宣布了任务锁定,这正是如此。不过它似乎确实需要root。
In the new Android L Preview, Google has announced Task Locking, which does exactly that. It does seem to need root however.
经过一段时间的搜索后,我想出了一个很好的解决方案。不过,这仅适用于已取得 root 权限的设备,但我想如果它仅适用于这个应用程序,那么取得 root 权限应该不是问题。
通过添加使您的应用程序成为启动器
到您的意图过滤器
确保您的应用程序折叠工具栏,以便您无法到达通知栏,请参阅如何以编程方式禁用 Android 上的状态栏/通知栏? 或 http://blog.vogella.com/ 2011/02/28/android-hidding-the-status-and-title-bar/
然后,要阻止任何其他程序错误打开,请使用辅助功能服务检查窗口状态是否已更改,进行比较将程序包添加到白名单或黑名单中,如果不应运行,则使用 ActivityManager.killBackgroundProcesses 将其终止。
另请查看 http://thebitplague。 wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/ 另一种方式
After searching for this for a while I've come up with a good solution. This only works on rooted devices though, but I guess if it's just for this one app then rooting it shouldn't be a problem.
Make your application the launcher by adding
to your intent-filter
Make sure your app collapses the toolbar so you cannot reach the notification bar see How to disable status bar / notification bar on android programmatically? or http://blog.vogella.com/2011/02/28/android-hidding-the-status-and-title-bar/
Then to stop any other programs from opening by mistake use an Accessibility Service to check for Window State Changed, compare the package to a white or black list and use ActivityManager.killBackgroundProcesses to kill if it shouldn't run.
Also check out http://thebitplague.wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/ for another way
在启动时启动应用程序
实现此目的的最佳方法是将应用程序设置为启动器
锁定应用程序
最可靠的方法是使用具有 Lollipop 或更高版本的设备,并且
首先必须将应用程序设置为设备所有者。请注意,您的设备必须未配置:如果您已注册,则应恢复出厂设置并跳过帐户注册。
为了能够注册您的应用程序,您必须首先设置一个 DeviceAdminReceiver 组件:
一旦您拥有未配置的设备,您可以从 adb 启动以下命令(无需 root),
以避免 Android 询问用户固定权限你必须调用你的应用程序
setLockTaskPackages了!
终于
Starting your app on boot
the BEST way to accomplish this is setting your app as the launcher
Locking your app
the most reliable way is to use a device with Lollipop or greater and make use of
first you must set your app as the device owner. NB your device must be unprovisioned: if you registered it you should do a factory reset and skip the account registration.
to be able to register your app you must first setup a DeviceAdminReceiver component:
once you have an unprovisioned device you can launch the following command from adb (no root required)
to avoid android asking the user permissions to pin your app you must call
setLockTaskPackages
finally!
Google 最近发布了 Android Management API,它允许轻松为运行 Android 5.1 或更高版本的任何 Android 设备设置 kiosk 模式,并设置各种其他策略。
Google recently released the Android Management API which allows to easily set up kiosk mode for any Android devices running Android 5.1 or above, and also to set various other policies.
Android 开发人员的设置单一用途设备页面已经描述了您可以轻松访问的内容从那里知道更多的事情。
现在,可以轻松将 Android 6.0 Marshmallow 及更高版本设备配置为公司拥有的一次性 (COSU) 设备。
Set up Single-Purpose Devices Page of android developer have described this things you can easily get to know more things from there.
Now it is easy to configure Android 6.0 Marshmallow and later devices as corporate-owned, single-use (COSU) devices.
在此 论坛中找到了另一种可能的技术发布。引用该帖子:
http:// /www.basic4ppc.com/forum/basic4android-getting-started-tutorials/10839-android-kiosk-mode-tutorial.html
似乎有示例 kiosk 模式代码 ZIP 文件可供下载< /a>,也是。
Found another possible technique in this forum post. Quoting that post:
http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/10839-android-kiosk-mode-tutorial.html
There appears to be an example kiosk-mode code ZIP file available for download, too.
Xposed框架可以做到这一点。它需要 root,并且有可能无法在所有平台上运行。在 android.app.StatusBarManager 类中查找 disable() 方法。
在 Android 源代码中
在这里查看如何编写自己的模块:
Xpose开发教程
比你第一眼想象的要容易得多。祝你好运!
Xposed framework can do this. It needs root and there is a possibility that it won't work on every and all platforms. Look for disable() method in class android.app.StatusBarManager.
Here in Android source code
Look here on how to write your own module:
Xposed development tutorial
It's much easier than you think at first glance. Good Luck!
除了使用 BOOT 接收器设置您的应用程序之外,还有此答案为了防止状态栏扩展,此解决方案在 4.4 及更高版本上作为完整的信息亭应用程序运行:
放置在 onCreate() 中:
这将完全隐藏后退按钮、应用程序和主页按钮。
Along with setting up your application with a BOOT receiver, and this answer for preventing status bar expansion, this solution works on 4.4 and above as a complete kiosk app :
Place in your onCreate():
This will completely hide the back button, apps and home button.
Kiosk 模式只不过是在您打开 Android 设备时锁定单个或一组应用程序。这可以通过锁定任务模式来实现。当设备在锁定任务模式下运行时,用户通常无法看到通知、访问非白名单应用程序或返回主屏幕。
设备策略控制器 (DPC) 可以将系统处于锁定任务模式时可以运行的应用程序列入白名单。由于它是用于特定目的的专用设备,因此使用该设备的人无法离开锁定任务模式。 Android 5.0及以上版本的设备可以在锁定任务模式下运行。
第一步是通过 DPC 将应用程序列入白名单。
将可以在锁定任务模式下使用的应用程序列入白名单。
DPC 可以通过调用DevicePolicyManager.setLockTaskPackages()
白名单完成后,DPC 可以调用以下函数来启动锁定任务。
ActivityOptions.setLockTaskEnabled()
您可以在此处找到有关锁定任务模式的更多详细信息。 https://developer.android.com/work/dpc/专用设备/锁定任务模式
Kiosk mode is nothing but locking a single or set of applications when you switch on an android device. This can be achieved by lock task mode. When the device runs in lock task mode, users typically can’t see notifications, access non-whitelisted apps, or return to the home screen.
The Device policy controller (DPC) can whitelist the app that can run when the system is in lock task mode. Since its a dedicated device for a specific purpose the person using the device can't leave lock task mode. The device which are Android 5.0 and higher can run in lock task mode.
First step is to whitelist the application by DPC.
DPC can whitelist the apps which can be used in lock task mode by calling
DevicePolicyManager.setLockTaskPackages()
Once the whitelisting is done, DPC can call the below function to start the lock task.
ActivityOptions.setLockTaskEnabled()
You can find more details regarding the lock task mode here. https://developer.android.com/work/dpc/dedicated-devices/lock-task-mode