简体   繁体   English

在Android中禁用/隐藏状态栏

[英]Disable/Hide status bar in Android

I am developing an application which should have some extra security features. 我正在开发一个应该具有一些额外安全功能的应用程序。 In this case I have to disable/hide the status bar. 在这种情况下,我必须禁用/隐藏状态栏。 I am running with Android 2.2. 我正在运行Android 2.2。

And also my device is rooted and if there is an ADB command to disable status bar, it would be fine as well. 而且我的设备也是root的,如果有一个ADB命令来禁用状态栏,它也会没问题。

For now what I do is basically when user try to expand the status bar I collapse it by invoking some . 现在我所做的基本上是当用户尝试扩展状态栏时我通过调用一些来折叠它。 But sometimes user can expand it and click on the items in status bar notifications. 但有时用户可以展开它并单击状态栏通知中的项目。

This code part will do this, 这段代码部分会这样做,

 public void onWindowFocusChanged(boolean hasFocus)
 {
         try
         {
            if(!hasFocus)
            {
                 Object service  = getSystemService("statusbar");
                 Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
                 Method collapse = statusbarManager.getMethod("collapse");
                 collapse .setAccessible(true);
                 collapse .invoke(service); 
            }
         }
         catch(Exception ex)
         {

         }
 }

And also I tried setting application as full screen app. 我还尝试将应用程序设置为全屏应用程序。 But it also has some problems. 但它也有一些问题。

Can someone please help me to solve this issue? 有人可以帮我解决这个问题吗?

Can someone please help me to do this? 有人可以帮我这样做吗?

you can select the theme spinner and select the "Theme.NoTitleBar.Fullscreen". 您可以选择主题微调器并选择“Theme.NoTitleBar.Fullscreen”。

Using code:- 使用代码: -

requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

above written code placed in oncreate method 上面写的代码放在oncreate方法中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM