如何在Android(4.1.1)中隐藏和显示系统栏

问题描述 投票:1回答:1

我需要在我的应用程序中显示和隐藏系统栏,因此我为此使用了两个按钮。我曾经同时测试过Android(3.0.1)和Android(4.1.1)设备。对于Android(3.0.1),我可以根据需要隐藏和显示系统栏。但是在Android(4.1.1)中,按钮无法隐藏和显示系统栏。

我的代码是

// Showing system bar
    showSystemBarBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {
                Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
                proc.waitFor();
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    });

    // Hiding System bar
    hideSystemBarBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            try {
                Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
                proc.waitFor();
            } catch(Exception e){
                e.printStackTrace();
            }
        }
    });

我该如何解决这个问题?

android performance statusbar android-notifications android-theme
1个回答
0
投票

隐藏:

Process proc = Runtime.getRuntime()。exec(new String [] {“ su”,“-c”,“服务调用活动79 s16 com.android.systemui”});

“尝试将“ 79”更改为“ 42”。

引入ICS时,SystemUI类的进程ID从79更改为42。

© www.soinside.com 2019 - 2024. All rights reserved.