My application consists of a ViewPager that displays images and videos. The application should enter the breathtaking view of the crane and exit the breathtaking view of the crane after 3 seconds. I also want the status bar to always be hidden. This basically works, however ...
I use a variation of the SystemUIHider classes that are created in Android Studio. I created a new class called SystemUIHiderKitKat that uses these flags. When you click on the screen, the navigation and actions panel (not the status bar) will be displayed. Clicking for 3 seconds will hide the navigation and status bar. And waiting more than 3 seconds will automatically hide the navigation and action panels.
Video of bars functioning as expected, but without MediaController: Working
Video bars do not work correctly when switching MediaController: Does not work
mShowFlags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
mHideFlags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE;
mTestForHiddenFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
My VideoView and MediaController are members of a custom FrameLayout class
public class MyVideoView extends FrameLayout
{
setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener()
{
@Override
public void onSystemUiVisibilityChange(int visibility)
{
final int hidden = SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_FULLSCREEN;
if ((hidden & visibility) != 0) {
m_mediaController.hide();
}
else {
m_mediaController.show();
}
}
});
If I comment on lines A and B, everything works fine (a “working” video). If lines A and B are not commented out, then when I click the "Action" button, it is hidden, but the navigation bar does not appear (the video "Doesn't work"). After a second or two, the delayedHide (int delayMillis) method receives a call, and then the navigation bar hides (!!). Now this puzzles me, because it calls the same hide () method and mAnchorView.setSystemUiVisibility (mHideFlags) is called with the same flag value as the first call (obviously)