简体   繁体   中英

Hide Navigation Bar when starting the Daydream service?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM