Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-隐藏通知栏,但保留导航栏_Android_Reflection_Root_Android Notifications_Statusbar - Fatal编程技术网

Android-隐藏通知栏,但保留导航栏

Android-隐藏通知栏,但保留导航栏,android,reflection,root,android-notifications,statusbar,Android,Reflection,Root,Android Notifications,Statusbar,我正在为Android创建一种信息亭应用程序,但我必须禁用通知栏,以避免客户访问Wifi、蓝牙或GPS快速访问 到目前为止,我已经为设备设置了根目录,并禁用了com.android.systemui包来实现这一点。主要的问题是,因为我只有虚拟的按钮来导航,我不能返回或回到主屏幕。基本上,我的申请程序被卡住了,我什么都做不了 我已使用该代码禁用SystemUI包: 然后,我尝试使用Java反射API禁用通知栏。到目前为止,我已经编写了该代码,但它不起作用。基本上,它只是抛出一个异常,说我的应用程序

我正在为Android创建一种信息亭应用程序,但我必须禁用通知栏,以避免客户访问Wifi、蓝牙或GPS快速访问

到目前为止,我已经为设备设置了根目录,并禁用了com.android.systemui包来实现这一点。主要的问题是,因为我只有虚拟的按钮来导航,我不能返回或回到主屏幕。基本上,我的申请程序被卡住了,我什么都做不了

我已使用该代码禁用SystemUI包:

然后,我尝试使用Java反射API禁用通知栏。到目前为止,我已经编写了该代码,但它不起作用。基本上,它只是抛出一个异常,说我的应用程序没有所需的权限android.permission.STATUS\u BAR,而它写在我的清单中

我是不是在代码的那部分出错了

另一种方法是创建一个系统覆盖来创建我自己的导航栏,但我还没有找到一种合适的方法来触发整个系统的按键事件,就好像它是真正的按钮一样。但是老实说,我不认为这是最好、最干净的解决方案

非常感谢您的帮助。

在styles.xml中:

<resources>
   <style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
   <item name="android:windowNoTitle">false</item>
   <item name="android:windowFullscreen">true</item>
   </style>
</resources>
在代码中,它看起来像

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Remove System bar (and retain title bar)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Set your layout
        setContentView(R.layout.main);
    }
}

使用该代码仍然可以访问通知栏。如果用户从上到下滑动,通知栏会出现并且可以访问。让我检查一下我这边的解决方案,这在根设备中是可能的。我目前没有根设备。
<resources>
   <style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
   <item name="android:windowNoTitle">false</item>
   <item name="android:windowFullscreen">true</item>
   </style>
</resources>
<activity android:name=".MyActivity" android:theme="@style/Theme.FullScreen"/>
// Remove System bar (and retain title bar)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                 WindowManager.LayoutParams.FLAG_FULLSCREEN);
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Remove System bar (and retain title bar)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Set your layout
        setContentView(R.layout.main);
    }
}