ANDROID 隐藏 任务栏 systemui systembar 全屏显示
16lz
2021-01-25
ANDROID 隐藏 任务栏 systemui systembar 全屏显示
转自: http://blog.csdn.net/xiao__ge/article/details/8662464 2013-03-12 10:40 1015人阅读 评论(26) 收藏 举报
说说自己的经历吧:
(1)开始为了隐藏systemui利用过 kill com.android.systemui线程进行的隐藏,但是总有一个com.android.systemui.SystemUIService进行启动
我开始还是比较的坏的就弄了一个监听每500毫秒进行检测一次进行查杀
代码:
[java] view plain copy print ?- @Override
- publicvoidonCreate(BundlesavedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- ActivityManageram=(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);//获得activity管理
- List<RunningAppProcessInfo>infos=am.getRunningAppProcesses();
- for(RunningAppProcessInforunningAppProcessInfo:infos){
- System.out.println("processName:====================:"+runningAppProcessInfo.processName);
- if(runningAppProcessInfo.processName.equals("com.android.systemui")){
- System.out.println("processpid:"+runningAppProcessInfo.pid);
- Stringstr="/system/bin/kill"+runningAppProcessInfo.pid;
- System.out.println("str:"+str);
- Processprocess;
- Runtimeruntime;
- try{
- runtime=Runtime.getRuntime();
- process=runtime.exec("su");
- System.out.println("01010101010");
- process=runtime.exec(str);
- intexitVal=process.waitFor();
- System.out.println("66666666666666666666666");
- break;
- }catch(IOExceptione){
- System.out.println(e);
- }catch(InterruptedExceptione){
- //TODOAuto-generatedcatchblock
- e.printStackTrace();
- }
(2)通过长时间研究我研究到了SystemUI.apk,我就就想对这个东西进行操作了。开始我删除掉后,systeui还是运行着,我就用kill命令直接杀掉这个线程,然后就开始报错了。说找不到SystemUI什么的。及其的烦人,不过重新启动就可以了。就没有那个错误了。
苍天真的不负有心人,本人找到一个更好的方法,原来大概是这样的:通过命令移除SystemUI.apk放到一个文件夹中,然后重新启动com.systemui.SystemUIService这个服务
就可以了。如果想恢复就把SystemUI.apk移到/system/app/下并且重新启动com.systemui.SystemUIService这个服务
代码参照:
[java] view plain copy print ?- FilesystemUIapkFile=newFile("/system/app/SystemUI.apk");
- @Override
- publicvoidonCreate(BundlesavedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- finalToggleButtonsystemBarToggleButton=(ToggleButton)findViewById(R.id.systemBarToggleButton);
- systemBarToggleButton.setChecked(systemUIapkFile.exists());
- systemBarToggleButton.setOnCheckedChangeListener(newOnCheckedChangeListener(){
- @Override
- publicvoidonCheckedChanged(CompoundButtonbuttonView,booleanisChecked){
- systemBarToggleButton.setChecked(isChecked);
- switchSystemUI();
- if(isChecked){
- Intentintent=newIntent();
- intent.setComponent(newComponentName(
- "com.android.systemui",
- "com.android.systemui.SystemUIService"));
- startService(intent);
- }
- }
- });
- }
- privatevoidswitchSystemUI(){
- try{
- Processp;
- p=Runtime.getRuntime().exec("su");
- //Attempttowriteafiletoaroot-only
- DataOutputStreamos=newDataOutputStream(p.getOutputStream());
- os.writeBytes("mount-oremount,rw/dev/block/stl6/system\n");
- if(systemUIapkFile.exists()){
- os.writeBytes("mv/system/app/SystemUI.apk/system/SystemUI.apk\n");
- }else{
- os.writeBytes("mv/system/SystemUI.apk/system/app/SystemUI.apk\n");
- }
- os.writeBytes("mount-oremount,ro/dev/block/stl6/system\n");
- //Closetheterminal
- os.writeBytes("exit\n");
- os.flush();
- p.waitFor();
- }catch(Exceptione){
- ShowErrorGlobal(e);
- }
- }
- protectedvoidShowErrorGlobal(Exceptione){
- ByteArrayOutputStreambaos=newByteArrayOutputStream();
- PrintStreamstream=newPrintStream(baos);
- e.printStackTrace(stream);
- stream.flush();
- newAlertDialog.Builder(this)
- .setIconAttribute(android.R.attr.alertDialogIcon)
- .setTitle("Epicfail")
- .setMessage("Error:"+newString(baos.toByteArray())).show();
- }
(3)
这种更牛逼,什么还自己通过命令操作。都是也路子。人家google给咱提供的有接口直接用就行啊
直接代码参考吧:
[java] view plain copy print ?- intflag=context.getWindow().getDecorView().getSystemUiVisibility();
- //intfullScreen=View.SYSTEM_UI_FLAG_SHOW_FULLSCREEN;
- intfullScreen=0x8;
- if(visible){
- if((flag&fullScreen)!=0){
- context.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
- }
- }else{
- if((flag&fullScreen)==0){
- context.getWindow().getDecorView().setSystemUiVisibility(flag|fullScreen);
- }
- }
如果有什么疑问可以留下,尽量解决。
点击打开链接
源码下载地址
更多相关文章
- 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
- GitHub 标星 2.5K+!教你通过玩游戏的方式学习 VIM!
- 如何在后台运行Linux命令?
- No.11 使用firewall配置的防火墙策略的生效模式
- android wifi ralink rt3070开发记录
- Handler Looper Message源码研究
- android 关于Canvas保存到本地图像
- 线程间通信----Handler
- Android实现关机重启的方法分享