Andrid 永久隐藏导航栏与系统栏

public void showSystembar(boolean makeVisible) {  
       checkInitialized();  
       try {  
           // get the existing environment  
           ArrayList<String> envlist = new ArrayList<String>();  
           Map<String, String> env = System.getenv();  
           for (String envName : env.keySet()) {  
               envlist.add(envName + "=" + env.get(envName));  
           }  
           String[] envp = (String[]) envlist.toArray(new String[0]);  
           // depending on makeVisible, show or hide the bar  
           if (makeVisible) {  
               Log.v(TAG, "showBar will show systembar");  
               // execute in correct environment  
               String command;  
               Device dev = Device.getInstance();  
               if (dev.getAndroidVersion() == AndroidVersion.HC) {  
                   command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
               //The four nucleus Tablet hide or display systemui  
               } else if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
                   command = "su -c am startservice -n com.android.systemui/.SystemUIService ";  
               //The four nucleus Tablet hide or display systemui  
               } else {  
                   command = "rm /sdcard/hidebar-lock\n"  
                           + "sleep 5\n"  
                           + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
               }  
               //The four nucleus Tablet hide or display systemui  
               if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
                Runtime.getRuntime().exec(command);  
               } else{  
                 Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);   
               }  
               //The four nucleus Tablet hide or display systemui  
               // no proc.waitFor();  
               // we just shown the bar, set flag to visible  
               mSystembarVisible = true;  
           } else {  
               Log.v(TAG, "showBar will hide the systembar");  
               // execute in correct environment  
               String command;  
               Device dev = Device.getInstance();  
               if (dev.getAndroidVersion() == AndroidVersion.HC) {  
                   command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib service call activity 79 s16 com.android.systemui";  
               //The four nucleus Tablet hide or display systemui  
               } else if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
                   command = "su -c service call activity 42 s16 com.android.systemui";  
               //The four nucleus Tablet hide or display systemui  
               } else {  
                   command = "touch /sdcard/hidebar-lock\n"  
                           + "while [ -f /sdcard/hidebar-lock ]\n"  
                           + "do\n"  
                           + "killall com.android.systemui\n"  
/                            + "sleep 1\n"  
                           + "usleep 500000\n"  
                           + "done\n"  
                           + "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";  
               }  
               //The four nucleus Tablet hide or display systemui  
               if(dev.getAndroidVersion() == AndroidVersion.JELLYBEAN4_2) {  
                Runtime.getRuntime().exec(command);  
               } else{  
                 Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);   
               }  
               //The four nucleus Tablet hide or display systemui  
               // no proc.waitFor();  
               // we just hide the bar, set flag to not visible  
               mSystembarVisible = false;  
           }  
       } catch (Exception e) {  
           e.printStackTrace();  
       }  
   }  
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值