简体   繁体   English

启动Daydream服务时隐藏导航栏?

[英]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. 我正在将Dreamservice添加到我的应用程序中,我希望在梦中播放视频。 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. 导致Daydream崩溃。 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. 否则,我在Daydream中播放的视频无法正确居中。

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. getWindow()getDecorView()任何一个都可能返回null ,尤其是在不做梦时。

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. 如果DreamService是交互式的,它也不会在第一个输入事件上DreamService ,只是在第二个输入事件上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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