【发布时间】:2012-01-06 13:47:36
【问题描述】:
我正在尝试创建一个按钮,我可以在其中隐藏或显示平板电脑上的状态栏。
我已经加入了 onCreate
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
在按钮中 显示:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
隐藏:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
任何提示/提示?
//编辑
我在这里看到了这个提示:http://android.serverbox.ch/?p=306 并像这样更改了我的代码:
private void hideStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();
}
private void showStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();
}
因此,如果我单击按钮并调用方法,我可以看到正在发生的事情,因为应用程序正在等待几秒钟。 我还查看了 LockCat,发现发生了一些事情。
显示:http://pastebin.com/CidTRSTi 隐藏:http://pastebin.com/iPS6Kgbp
【问题讨论】:
标签: android show-hide statusbar