我有一个Android Jelly Bean平板电脑已经植根并尝试运行一个应用程序,该应用程序具有隐藏系统栏的代码,但它没有被隐藏,任何人都可以帮助我解决这个问题。
在终端获取输出: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();
}
}
});
}
}
虽然我正在获得许可的祝贺:
超级用户日志屏幕截图:
答案 0 :(得分:22)
引入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","-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();
}
答案 1 :(得分:2)
我写了一篇文章解释了如何获取root权限,并在Android 4.2上隐藏/显示系统栏
http://masashi-k.blogspot.com/2013/09/hide-show-system-bar-of-android.html
使用RootTools库获取root权限。
隐藏系统栏