Hide System Bar in Jelly Bean Tablet (Rooted)

2019-02-01 02:50发布

I have an Android Jelly Bean Tablet which has been rooted and trying to run an application which has the code to hide the system bar but it's not getting hidden can any one help me out on this.

Getting output in terminal : Result Parcel(00000000 '....')

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button hide=(Button)findViewById(R.id.button1);
        Button show=(Button)findViewById(R.id.button2);
        hide.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                 Log.v("ds", "hideSystembar");
                    try {
                        Process proc = Runtime.getRuntime().exec(new String[]{
                                "su","-c","service call activity 79 s16 com.android.systemui"});
                        proc.waitFor();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
            }
        });
        show.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                  Log.v("f", "showSystembar");
                    try {
                        Process proc = Runtime.getRuntime().exec(new String[]{
                                "am","startservice","-n","com.android.systemui/.SystemUIService"});
                        proc.waitFor();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
            }
        });
    }
} 

Though I am getting toast of permission granted :enter image description here

Super User Log Screen Shot: enter image description here

标签: android root
2条回答
劳资没心,怎么记你
2楼-- · 2019-02-01 03:07

The process id for the SystemUI class changed from 79 to 42 when ICS was introduced.
The code below works for any version of Android that your app might be running on.

//HIDE TOOLBAR
try{
    //REQUIRES ROOT
    Build.VERSION_CODES vc = new Build.VERSION_CODES();
    Build.VERSION vr = new Build.VERSION();
    String ProcID = "79"; //HONEYCOMB AND OLDER

    //v.RELEASE  //4.0.3
    if(vr.SDK_INT >= vc.ICE_CREAM_SANDWICH){
        ProcID = "42"; //ICS AND NEWER
    }

    //REQUIRES ROOT
    Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity "+ ProcID +" s16 com.android.systemui"}); //WAS 79
    proc.waitFor();

}catch(Exception ex){
    Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
}
查看更多
我命由我不由天
3楼-- · 2019-02-01 03:23

I wrote an article that explains how to obtain root permission, and hide / show the system bar even on Android 4.2

http://masashi-k.blogspot.com/2013/09/hide-show-system-bar-of-android.html

Get root permission using RootTools library. enter image description here

Hide the system bar enter image description here

查看更多
登录 后发表回答