3

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.

Bradley Bossard
  • 2,439
  • 2
  • 23
  • 30

1 Answers1

2

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.

tynn
  • 38,113
  • 8
  • 108
  • 143
  • 1
    I know this post is quite old now but since it is the only thing that would come up in a search, I want to document the fact that for me, setting `View.SYSTEM_UI_FLAG_HIDE_NAVIGATION` wasn't enough. I also had to use `View.SYSTEM_UI_FLAG_IMMERSIVE`. Not sure why. I should also mention that it works if you simply call it once in `onAttachedToWindow()`. It also will not return null in that case since there will be a window when it is called. – Kaamil Jasani Jul 21 '18 at 17:51