Android 永久隐藏导航栏,系统栏的方法

  1. 文章来自:http://blog.csdn.net/moliyll/article/details/41945083

  2. public void showSystembar(boolean makeVisible) {  
  3.        checkInitialized();  
  4.        try {  
  5.            // get the existing environment  
  6.            ArrayList<String> envlist = new ArrayList<String>();  
  7.            Map<String, String> env = System.getenv();  
  8.            for (String envName : env.keySet()) {  
  9.                envlist.add(envName + "=" + env.get(envName));  
  10.            }  
  11.            String[] envp = (String[]) envlist.toArray(new String[0]);  
  12.            // depending on makeVisible, show or hide the bar  
  13.            if (makeVisible) {  
  14.                Log.v(TAG, "showBar will show systembar");  
  15.                // execute in correct environment  
  16.                String command;  
  17.                Device dev = Device.getInstance();  
  18.                if (dev.getAndroidVersion() == AndroidVersion.HC) {  
  19.                    command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
  20.                //The four nucleus Tablet hide or display systemui  
  21.                } else if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
  22.                    command = "su -c am startservice -n com.android.systemui/.SystemUIService ";  
  23.                //The four nucleus Tablet hide or display systemui  
  24.                } else {  
  25.                    command = "rm /sdcard/hidebar-lock\n"  
  26.                            + "sleep 5\n"  
  27.                            + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
  28.                }  
  29.                //The four nucleus Tablet hide or display systemui  
  30.                if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
  31.                 Runtime.getRuntime().exec(command);  
  32.                } else{  
  33.                  Runtime.getRuntime().exec(new String[] { "su""-c", command }, envp);   
  34.                }  
  35.                //The four nucleus Tablet hide or display systemui  
  36.                // no proc.waitFor();  
  37.                // we just shown the bar, set flag to visible  
  38.                mSystembarVisible = true;  
  39.            } else {  
  40.                Log.v(TAG, "showBar will hide the systembar");  
  41.                // execute in correct environment  
  42.                String command;  
  43.                Device dev = Device.getInstance();  
  44.                if (dev.getAndroidVersion() == AndroidVersion.HC) {  
  45.                    command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib service call activity 79 s16 com.android.systemui";  
  46.                //The four nucleus Tablet hide or display systemui  
  47.                } else if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
  48.                    command = "su -c service call activity 42 s16 com.android.systemui";  
  49.                //The four nucleus Tablet hide or display systemui  
  50.                } else {  
  51.                    command = "touch /sdcard/hidebar-lock\n"  
  52.                            + "while [ -f /sdcard/hidebar-lock ]\n"  
  53.                            + "do\n"  
  54.                            + "killall com.android.systemui\n"  
  55. /                            + "sleep 1\n"  
  56.                            + "usleep 500000\n"  
  57.                            + "done\n"  
  58.                            + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
  59.                }  
  60.                //The four nucleus Tablet hide or display systemui  
  61.                if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
  62.                 Runtime.getRuntime().exec(command);  
  63.                } else{  
  64.                  Runtime.getRuntime().exec(new String[] { "su""-c", command }, envp);   
  65.                }  
  66.                //The four nucleus Tablet hide or display systemui  
  67.                // no proc.waitFor();  
  68.                // we just hide the bar, set flag to not visible  
  69.                mSystembarVisible = false;  
  70.            }  
  71.        } catch (Exception e) {  
  72.            e.printStackTrace();  
  73.        }  
  74.    }  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值