我创建了一个启动器,以便在内部应用程序中使用它。出于某些安全原因,我想隐藏系统栏(访问参数和访问已安装应用程序的ordrer)。但我不知道该怎么做。 将使用的平板电脑不是root。 你能帮帮我吗?
答案 0 :(得分:13)
你无法隐藏它,但你可以禁用它,除了家。为此,您可以将您的应用程序作为主类别,并让用户选择。
<category android:name="android.intent.category.HOME" />
休息全部都可以禁用。
在清单中添加此内容。
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
在onCreate()
中this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_home);
View v = findViewById(R.id.home_view);
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
其中home_view是xml文件的父视图。
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
public void onWindowFocusChanged(boolean hasFocus)
{
try
{
if(!hasFocus)
{
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse .setAccessible(true);
collapse .invoke(service);
}
}
catch(Exception ex)
{
}
}
答案 1 :(得分:8)
您可以隐藏我使用此代码隐藏的底栏:
getWindow().getDecorView().setSystemUiVisibility(View.GONE);
将此代码用于带键盘或遥控器的android盒子。
答案 2 :(得分:1)
您可以使用SYSTEM_UI_FLAG_HIDE_NAVIGATION标志隐藏Android 4.0及更高版本上的导航栏。此代码段隐藏了导航栏和状态栏:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions
请参阅以下内容:Hiding the Navigation Bar