如何在Android LockScreen应用程序中禁用导航栏,例如CM储物柜和OS8锁定屏幕 [英] How to disable naviagation bar in Android LockScreen App like CM locker and OS8 lock screen
问题描述
我尝试设置systemUIView(View.GONE)并使用沉浸式全屏模式.但是,用户始终可以通过触摸屏幕底部来返回导航栏.我上面提到的应用程序可以隐藏它,而无需root用户或设置默认启动器.
I tried setting systemUIView(View.GONE) and use Immersive Full-Screen Mode. But users can always get the naviagtion bar back by touching the bottom of the screen. The apps i mentioned above are able to hide it without root or setting default launcher.
推荐答案
好的,我终于找到了解决方案,这是完成的过程:
Okay, I found a solution finally and here is how it's done:
-
使用
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
隐藏导航栏,如下所示,您可以将代码放在活动的onResume中
Use
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
to hide the navigation bar as follow, you may put the code inside onResume of your activity
查看decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions);
View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions);
然后,使用WindowManger添加系统错误窗口并将其覆盖在所有内容之上
Then, add a system error window using WindowManger and overlay it on top of everything
您可以将这个无法逃避的视图放置在您喜欢的任何位置,但是如果您想在用户锁定屏幕时执行此操作,请添加以下标志:
you can put this unescapable view anywhere you like, but if you want to do it while users locked the screen, add this flag:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
Etvoilà
这篇关于如何在Android LockScreen应用程序中禁用导航栏,例如CM储物柜和OS8锁定屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!