现在的位置: 首页 > 综合 > 正文

ANDROID 隐藏 任务栏 systemui systembar 全屏显示 ANDROID 隐藏 任务栏 systemui systembar 全屏显示

2014年01月16日 ⁄ 综合 ⁄ 共 5206字 ⁄ 字号 评论关闭

ANDROID 隐藏 任务栏 systemui systembar 全屏显示

http://blog.csdn.net/xiao__ge/article/details/8662464

 1015人阅读 评论(26) 收藏 举报

说说自己的经历吧:

(1)开始为了隐藏systemui利用过 kill com.android.systemui线程进行的隐藏,但是总有一个com.android.systemui.SystemUIService进行启动

                          我开始还是比较的坏的就弄了一个监听每500毫秒进行检测一次进行查杀

 

代码:

  1. @Override  
  2.     public void onCreate(Bundle savedInstanceState) {  
  3.         super.onCreate(savedInstanceState);  
  4.         setContentView(R.layout.main);  
  5.          ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);// 获得activity管理  
  6.   
  7.         List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();  
  8.         for (RunningAppProcessInfo runningAppProcessInfo : infos) {  
  9.             System.out.println("processName:====================:"+runningAppProcessInfo.processName);  
  10.             if(runningAppProcessInfo.processName.equals("com.android.systemui")){  
  11.                 System.out.println("processpid: "+runningAppProcessInfo.pid);  
  12.                     String str = "/system/bin/kill "+runningAppProcessInfo.pid;  
  13.                     System.out.println("str:  "+str);  
  14.                     Process process;  
  15.                     Runtime runtime;  
  16.                     try {  
  17.                         runtime = Runtime.getRuntime();  
  18.                         process = runtime.exec("su");  
  19.                         System.out.println("01010101010");  
  20.                         process = runtime.exec(str);  
  21.                          int exitVal = process.waitFor();  
  22.                         System.out.println("66666666666666666666666");  
  23.                         break;  
  24.                     } catch (IOException e) {  
  25.                         System.out.println(e);  
  26.                     } catch (InterruptedException e) {  
  27.                         // TODO Auto-generated catch block  
  28.                         e.printStackTrace();  
  29.                     }  


 

(2)通过长时间研究我研究到了SystemUI.apk,我就就想对这个东西进行操作了。开始我删除掉后,systeui还是运行着,我就用kill命令直接杀掉这个线程,然后就开始报错了。说找不到SystemUI什么的。及其的烦人,不过重新启动就可以了。就没有那个错误了。

苍天真的不负有心人,本人找到一个更好的方法,原来大概是这样的:通过命令移除SystemUI.apk放到一个文件夹中,然后重新启动com.systemui.SystemUIService这个服务

就可以了。如果想恢复就把SystemUI.apk移到/system/app/下并且重新启动com.systemui.SystemUIService这个服务

代码参照:

  1. File systemUIapkFile = new File("/system/app/SystemUI.apk");  
  2.      
  3.    @Override  
  4.    public void onCreate(Bundle savedInstanceState) {  
  5.        super.onCreate(savedInstanceState);  
  6.        setContentView(R.layout.main);  
  7.          
  8.        final ToggleButton systemBarToggleButton = (ToggleButton) findViewById(R.id.systemBarToggleButton);  
  9.        systemBarToggleButton.setChecked(systemUIapkFile.exists());  
  10.        systemBarToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {  
  11.            @Override  
  12.            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {  
  13.                systemBarToggleButton.setChecked(isChecked);  
  14.                switchSystemUI();  
  15.                if (isChecked) {  
  16.                    Intent intent = new Intent();  
  17.                    intent.setComponent(new ComponentName(  
  18.                            "com.android.systemui",  
  19.                            "com.android.systemui.SystemUIService"));  
  20.                    startService(intent);  
  21.                }  
  22.            }  
  23.        });  
  24.    }  
  25.      
  26.    private void switchSystemUI() {  
  27.        try {  
  28.            Process p;  
  29.            p = Runtime.getRuntime().exec("su");  
  30.   
  31.            // Attempt to write a file to a root-only  
  32.            DataOutputStream os = new DataOutputStream(p.getOutputStream());  
  33.            os.writeBytes("mount -o remount,rw /dev/block/stl6 /system\n");  
  34.            if (systemUIapkFile.exists()) {  
  35.                os.writeBytes("mv /system/app/SystemUI.apk /system/SystemUI.apk\n");  
  36.            }else {  
  37.                os.writeBytes("mv /system/SystemUI.apk /system/app/SystemUI.apk\n");  
  38.            }  
  39.            os.writeBytes("mount -o remount,ro /dev/block/stl6 /system\n");  
  40.   
  41.            // Close the terminal  
  42.            os.writeBytes("exit\n");  
  43.            os.flush();  
  44.            p.waitFor();  
  45.        } catch (Exception e) {  
  46.            ShowErrorGlobal(e);  
  47.        }  
  48.    }  
  49.      
  50.    protected void ShowErrorGlobal(Exception e) {  
  51.        ByteArrayOutputStream baos = new ByteArrayOutputStream();  
  52.        PrintStream stream = new PrintStream(baos);  
  53.        e.printStackTrace(stream);  
  54.        stream.flush();  
  55.   
  56.        new AlertDialog.Builder(this)  
  57.                .setIconAttribute(android.R.attr.alertDialogIcon)  
  58.                .setTitle("Epic fail")  
  59.                .setMessage("Error: " + new String(baos.toByteArray())).show();  
  60.    }  


(3)

这种更牛逼,什么还自己通过命令操作。都是也路子。人家google给咱提供的有接口直接用就行啊

直接代码参考吧:

  1. int flag = context.getWindow().getDecorView().getSystemUiVisibility();  
  2. //      int fullScreen = View.SYSTEM_UI_FLAG_SHOW_FULLSCREEN;  
  3.         int fullScreen = 0x8;  
  4.         if(visible) {  
  5.             if((flag & fullScreen) != 0) {  
  6.                 context.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);  
  7.             }  
  8.         } else {  
  9.             if((flag & fullScreen) == 0) {  
  10.                 context.getWindow().getDecorView().setSystemUiVisibility(flag | fullScreen);  

抱歉!评论已关闭.