Android hides the taskbar systemui systembar in full screen

Source: Internet
Author: User

Let's talk about our experiences:

(1) start to hide systemui by using the kill com. Android. systemui thread, but there is always a com. Android. systemui. systemuiservice to start

At first, I got a listener that detected and killed every 500 milliseconds.

 

Code:

@ Overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); activitymanager AM = (activitymanager) getsystemservice (context. activity_service); // obtain the activity management list <runningappprocessinfo> Infos = aM. getrunningappprocesses (); For (runningappprocessinfo: Infos) {system. out. println ("processname: =========================:" + runningappprocessinfo. processname); If (runningappprocessinfo. processname. equals ("com. android. systemui ") {system. out. println ("processpid:" + runningappprocessinfo. PID); string STR = "/system/bin/kill" + runningappprocessinfo. PID; system. out. println ("str:" + Str); process; runtime; try {runtime = runtime. getruntime (); process = runtime.exe C ("Su"); system. out. println ("01010101010"); process = runtime.exe C (STR); int exitval = process. waitfor (); system. out. println ("66666666666666666666666"); break;} catch (ioexception e) {system. out. println (E);} catch (interruptedexception e) {// todo auto-generated catch blocke. printstacktrace ();}

 

(2)after studying systemui.apk for a long time, I want to operate on it. After I delete the thread, systeui is still running. I will use the kill command to directly kill the thread and then start to report an error. The system UI cannot be found. It is annoying, but you can restart it. There is no such error.

Cangtian is really caring. I found a better method. It turned out to be like this: Transfer systemui.apk to a folder and restart the service com. systemui. systemuiservice.

You can. If you want to recover, move systemui.apk to/system/APP/and restart the service com. systemui. systemuiservice.

Code reference:

 File systemUIapkFile = new File("/system/app/SystemUI.apk");        @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);                final ToggleButton systemBarToggleButton = (ToggleButton) findViewById(R.id.systemBarToggleButton);        systemBarToggleButton.setChecked(systemUIapkFile.exists());        systemBarToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {            @Override            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {                systemBarToggleButton.setChecked(isChecked);                switchSystemUI();                if (isChecked) {                    Intent intent = new Intent();                    intent.setComponent(new ComponentName(                            "com.android.systemui",                            "com.android.systemui.SystemUIService"));                    startService(intent);                }            }        });    }        private void switchSystemUI() {        try {            Process p;            p = Runtime.getRuntime().exec("su");            // Attempt to write a file to a root-only            DataOutputStream os = new DataOutputStream(p.getOutputStream());            os.writeBytes("mount -o remount,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 -o remount,ro /dev/block/stl6 /system\n");            // Close the terminal            os.writeBytes("exit\n");            os.flush();            p.waitFor();        } catch (Exception e) {            ShowErrorGlobal(e);        }    }        protected void ShowErrorGlobal(Exception e) {        ByteArrayOutputStream baos = new ByteArrayOutputStream();        PrintStream stream = new PrintStream(baos);        e.printStackTrace(stream);        stream.flush();        new AlertDialog.Builder(this)                .setIconAttribute(android.R.attr.alertDialogIcon)                .setTitle("Epic fail")                .setMessage("Error: " + new String(baos.toByteArray())).show();    }

(3)

This is even more awesome. Both are the same path. What Google provides us with is an interface that can be used directly.

Direct code reference:

int flag = context.getWindow().getDecorView().getSystemUiVisibility();//int fullScreen = View.SYSTEM_UI_FLAG_SHOW_FULLSCREEN;int fullScreen = 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);}}

If you have any questions, try to solve them.

Click Open Link

Source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.