android – 在Jelly Bean平板电脑中隐藏系统栏(生根)

前端之家收集整理的这篇文章主要介绍了android – 在Jelly Bean平板电脑中隐藏系统栏(生根)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 Android Jelly Bean平板电脑已经扎根并且试图运行一个应用程序,其中包含隐藏系统栏的代码,但它没有被隐藏,任何人都可以帮助我解决这个问题.

获取终端输出:结果包(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();
                    }
            }
        });
    }
}

虽然我正在获得许可的祝酒:

超级用户日志屏幕截图:

@H_502_11@解决方法
当引入ICS时,systemUI类的进程ID从79更改为42.下面的代码适用于您的应用可能正在运行的任何Android版本.
//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","service call activity "+ ProcID +" s16 com.android.systemUI"}); //WAS 79
    proc.waitFor();

}catch(Exception ex){
    Toast.makeText(getApplicationContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
}
原文链接:https://www.f2er.com/android/317244.html

猜你在找的Android相关文章