Disable/Ask 用于显示顶部和底部导航栏之前的密码
Disable/Ask for password before showing top&bottom nav bar
在为平板电脑开发客户调查应用程序时,我意识到我必须禁止通知面板被拉出并隐藏底部导航,以防万一,对于所有那些 有趣 的客户努力成为一个聪明的***。
我使用的是非 root 设备,因此无法使用 this 答案中的反射。
And while adding
getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
will do the trick, it will also disable everything else.
我一开始要求应用全屏只是为了隐藏顶部栏,但这对底部导航栏没有任何作用。
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
因此我使用了Immersive Full-Screen Mode。它确实隐藏了顶部和底部栏,但当用户向上或向下滑动时,它们会再次出现。
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
The device runs on Android 4.4
我正在寻找一种方法来完全禁用它们或(最好的情况)在再次显示它们之前要求输入密码。
如果我理解你的问题,你正在寻找的是一个单一用途的设备,如果设备是 运行 Android,你可以使用 startLockTask()
函数实现你想要的5 及以上 https://developer.android.com/work/cosu.html#emm-solutions
The device owner must include your app’s package(s) in setLockTaskPackages
Sets the packages that can enter into lock task mode
Needs to be set by the EMM
You can call isLockTaskPermitted to verify that your package has been whitelisted by setLockTaskPackages.
Your activity calls startLockTask()
Requests to lock the user into the current task
Prevents launching other apps, settings, and the Home button
To exit, your activity must call stopLockTask()
Can only be called on an activity that’s previously called startLockTask()
Should be called when the app is user-facing between onResume()
and onPause()
您似乎可以在低于 5 的 Android 版本上使用这些操作实现相同的效果,如下所述:http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
Overview
A Kiosk Mode is implemented by disabling various Android
features that can be used to leave your app. The following features
are affected:
- The back button
- The home button
- The recent apps button
- The power button
- The volume buttons
工作量可能比您想要的要多,但您可以开发自定义启动器以防止退出调查应用程序,或者在退出启动器时立即re-launch它在这种情况下是默认主屏幕 activity 启动界面...这至少适用于 Android 的情人版本。不过,我希望它会做很多工作,尤其是 "plug" 您的用户可能会发现的所有小 get-arounds 和漏洞(进入设置等)
在为平板电脑开发客户调查应用程序时,我意识到我必须禁止通知面板被拉出并隐藏底部导航,以防万一,对于所有那些 有趣 的客户努力成为一个聪明的***。
我使用的是非 root 设备,因此无法使用 this 答案中的反射。
And while adding
getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
will do the trick, it will also disable everything else.
我一开始要求应用全屏只是为了隐藏顶部栏,但这对底部导航栏没有任何作用。
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
因此我使用了Immersive Full-Screen Mode。它确实隐藏了顶部和底部栏,但当用户向上或向下滑动时,它们会再次出现。
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
The device runs on Android 4.4
我正在寻找一种方法来完全禁用它们或(最好的情况)在再次显示它们之前要求输入密码。
如果我理解你的问题,你正在寻找的是一个单一用途的设备,如果设备是 运行 Android,你可以使用 startLockTask()
函数实现你想要的5 及以上 https://developer.android.com/work/cosu.html#emm-solutions
The device owner must include your app’s package(s) in setLockTaskPackages Sets the packages that can enter into lock task mode Needs to be set by the EMM You can call isLockTaskPermitted to verify that your package has been whitelisted by setLockTaskPackages. Your activity calls
startLockTask()
Requests to lock the user into the current task Prevents launching other apps, settings, and the Home button To exit, your activity must callstopLockTask()
Can only be called on an activity that’s previously calledstartLockTask()
Should be called when the app is user-facing betweenonResume()
andonPause()
您似乎可以在低于 5 的 Android 版本上使用这些操作实现相同的效果,如下所述:http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
Overview
A Kiosk Mode is implemented by disabling various Android features that can be used to leave your app. The following features are affected:
- The back button
- The home button
- The recent apps button
- The power button
- The volume buttons
工作量可能比您想要的要多,但您可以开发自定义启动器以防止退出调查应用程序,或者在退出启动器时立即re-launch它在这种情况下是默认主屏幕 activity 启动界面...这至少适用于 Android 的情人版本。不过,我希望它会做很多工作,尤其是 "plug" 您的用户可能会发现的所有小 get-arounds 和漏洞(进入设置等)