5

I am developing an application for tablet only, where the requirement is to run the app on the full screen of the tablet.

For this I have used following code in my main activity:

getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

This code snippet only removes the title bar and action bar. But in tablets, there is a bottom system bar (having home and back button). I also want to remove or hide this system bar too.

I have searched but there is only following solution:

  1. There is no API to remove or hide the system bar.
  2. You can use some android app to hide system bar. (for example: surelock, hidebar, etc)

My question is :

  1. Is it really not possible in android?
  2. Above available app (i.e surelock, hide bar, etc) also hiding bar. It means they are using something to do so. Can be use this something in our app so the user will not require to download these app seperatly.

Please guide me.

I know this is not a good idea. But My app is only for tablet having Android 4.0 or greater and that tablet will run only this single app so we do not need to go back and use home button. That's why my requirement is to use the app in full screen.

4

4 回答 4

9

如果您具有 root 访问权限,则可以使用此代码,否则不允许

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();
}

看到这个

于 2013-04-17T10:11:15.507 回答
8

在 Android API 4.0 及更高版本中,您可以使用以下代码隐藏底部系统栏。

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
于 2014-05-28T11:05:11.607 回答
5

除非您具有 root 访问权限,否则这是不可能的。或者,您可以创建一个launcher application.

否则隐藏系统/导航栏将超出您的应用程序的范围。

于 2013-04-17T10:05:50.170 回答
0

在互联网上进行了大量搜索后,我设法让系统栏隐藏并出现在 4.2 设备中,使用:

隐藏:

Runtime.getRuntime().exec("service call activity 42 s16 com.android.systemui");

或者对于小于 14 的 API 使用 79 而不是 42。您可能还需要包含 SET_DEBUG_APP 权限,在这种情况下,您需要使用系统密钥对应用程序进行签名或安装在 /system/app/ 目录中。

以显示:

Runtime.getRuntime().exec("am startservice --user 0 -n com.android.systemui/.SystemUIService");

或者,有些人使用了 -a(而不是 -n)选项,尽管这导致我的设备出现错误:

错误:未找到;没有服务启动。

于 2013-10-15T04:59:10.083 回答