在Android中禁用/隐藏状态栏 [英] Disable/Hide status bar in Android

查看:1405
本文介绍了在Android中禁用/隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发应该有一些额外的安全功能的应用程序。在这种情况下,我必须禁用/隐藏状态栏。我与Android 2.2的运行。

也是我的设备是植根,如果有一个ADB命令关闭状态栏,它会被罚款,以及

现在我做的基本上是当用户试图展开状态栏我通过调用一些折叠它。但有时用户可以展开它并点击状态栏通知的项目。

这code部分将做到这一点,

 公共无效onWindowFocusChanged(布尔hasFocus)
 {
         尝试
         {
            如果(!hasFocus)
            {
                 对象服务= getSystemService(状态栏);
                 类<> statusbarManager =的Class.forName(android.app.StatusBarManager);
                 方法崩溃= statusbarManager.getMethod(崩溃);
                 崩溃.setAccessible(真);
                 崩溃.invoke(服务);
            }
         }
         赶上(异常前)
         {         }
 }

和我也试着设置应用程序,全屏应用程序。但它也有一些问题。

有人可以帮我解决这个问题?

有人可以帮我做到这一点?


解决方案

  

您可以选择主题微调,并选择
  Theme.NoTitleBar.Fullscreen。


  
  

使用code: -


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


  

上面写code放置在onCreate方法


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.

And also my device is rooted and if there is an ADB command to disable status bar, it would be fine as well.

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".

Using code:-

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

above written code placed in oncreate method

这篇关于在Android中禁用/隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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