Android锁定全屏 [英] Android locked fullscreen

查看:115
本文介绍了Android锁定全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Android上锁定全屏?基本上隐藏吐司,隐藏主页/后退/切换,隐藏通知栏,使其从底部或顶部滑动不起作用.

Is it possible to lock fullscreen on Android? Basically hide toasts, hide home/back/switch, hide notification bar, make it so swiping from bottom or top doesn't work.

致力于一个可以从中受益匪浅的想法.我知道做我描述的事情很不好,但是它针对的是很小的孩子,他们会随机点击/拖动并偶尔将您的电话语言偶然更改为中文.

Working on an idea that would benefit greatly from this. I know it's bad to do what I described, but it's aimed at very young children who randomly tap/drag and occasionally change your phone language to Chinese by accident.

推荐答案

根据您要定位的Android版本,您可以使用屏幕固定.

Depending on the version of Android you're targeting you could use Screen Pinning.

从Android文档( https://developer.android.com/about/版本/android-5.0.html ):

From Android Documentation (https://developer.android.com/about/versions/android-5.0.html):

屏幕固定

Android 5.0引入了新的屏幕固定API,可让您临时限制用户离开任务或被通知打扰.例如,如果您正在开发教育应用程序以支持Android或单一用途或信息亭应用程序上的高风险评估要求,则可以使用此功能.您的应用激活屏幕固定后,用户将无法查看通知,访问其他应用或返回主屏幕,直到您的应用退出该模式.

Android 5.0 introduces a new screen pinning API that lets you temporarily restrict users from leaving your task or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android, or a single-purpose or kiosk application. Once your app activates screen pinning, users cannot see notifications, access other apps, or return to the home screen, until your app exits the mode.

有两种方法可以激活屏幕固定:

There are two ways to activate screen pinning:

  • 手动:用户可以在设置">安全性">启用屏幕固定" 屏幕固定,然后通过触摸选择要固定的任务 最近屏幕中的绿色图钉图标.
  • 以编程方式:激活 屏幕以编程方式固定,请从您的应用中调用startLockTask(). 如果发出请求的应用不是设备所有者,则会提示用户输入 确认.设备所有者应用程序可以调用setLockTaskPackages() 在无需用户确认的情况下使应用程序可固定的方法 步骤.
  • Manually: Users can enable screen pinning in Settings > Security > Screen Pinning, and select the tasks they want to pin by touching the green pin icon in the recents screen.
  • Programmatically: To activate screen pinning programmatically, call startLockTask() from your app. If the requesting app is not a device owner, the user is prompted for confirmation. A device owner app can call the setLockTaskPackages() method to enable apps to be pinnable without the user confirmation step.

激活任务锁定后,会发生以下行为:

When task locking is active, the following behavior happens:

  • 状态栏为空白,并且用户通知和状态信息被隐藏.
  • 主页"和最近使用的应用程序"按钮被隐藏.
  • 其他应用无法启动新活动.
  • 当前应用可以启动新活动,只要这样做不会创建新任务即可.
  • 当设备所有者调用屏幕固定时,用户将保持锁定到您的应用程序,直到该应用程序调用stopLockTask().
  • 如果屏幕固定是由不是设备所有者的另一个应用或用户直接进行的,则用户可以同时按住后退"和最近"按钮退出.

这篇关于Android锁定全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆