Hide Navigation Bar when starting the Daydream service?

974 Views Asked by At

I am adding the Dreamservice to my app, where I would like to play a video during the dream. Roughly the same code I use to hide the navigation control during my Main Activity

// Hide navigation controls
View v = findViewById(R.id.dream);
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

causes the Daydream to crash. Looking at some other Daydreams, it seems like none of them hide the bar either. Is it possible to do this? Otherwise, the video I am playing during the Daydream isn't able to center properly.

1

There are 1 best solutions below

1
On

Try a little different approach.

View view = getWindow().getDecorView();
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | view.getSystemUiVisibility());

Any of getWindow() or getDecorView() might return null, especially when not dreaming.

Keep the docs in mind. You might need to reapply this flag regularly. If the DreamService is interactive, it will not dismiss on the first input event either, just on the second.