I'm developing an app for a client that wants to use a tablet as a display of interactive ads and games. The tablet will be placed in a holder that will avoid the use of any physical button.
I'm trying to get the app to run fullscreen, and upon swiping from the top I'd like the app to remain fullscreen. But for a moment the status bar appears and so do the buttons.
The code of my activity:
public class OrderActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order);
hideSystemUi();
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
new OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if (visibility == 0) {
hideSystemUi();
}
}
});
}
private void hideSystemUi() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
}
PD: I know that this behaviour is frowned upon in app from the marketplace, but it's what's required and "correct" in this specific case.