Disable touchs and UI in VideoView in fullscreen kiosk mode? - android

I need to run VideoView in splash kiosk mode.
So I set it to fullscreen (all UI hidden, LOW_PROFILE etc). Mediacontroller not set and not exists. videoview set to not clickable in xml. VideoView OnTouch method overrided. Zorder set to -1. I tried all methods...
but!
Any touch of running VideoView shows me bottom navigation bar (back, home etc) on tablet.
System hides it automatically at 3 seconds. I can not override it :(
How to make VideoView in fullscreen - fully untouchable?

I found a solution, never seen it here.
this totally disables bottom UI on tablet (but leave upper bar on phone)
videoView.setSystemUiVisibility(View.GONE);
to hide status on phone just set in activity onCreate as usual:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_fullscreen);

Have been fighting with this for a while, and it turns out nothing happens if you set the flags on the VideoView, but works when you do it on the mediaController:
mediaController.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
A remaining problem is that the video now doesn't seem to respond to touch at all, so the media controls are also gone.

Related

Xamarin.Forms Android immersive mode with soft keyboard or Alert

I am trying to get my Xamarin.Forms application to use Android's immersive mode, since I am using a device with small screen, so soft keys and navigation bar is stealing my precious screen real estate.
Since the device I am using features hardware keyboard, I wanted to hide the soft keyboard. Currently I solved this by installing a "Null Input Method" keyboard. The keyboard is still there however, so every time focus is requested on Entry element, the keyboard is "shown". This causes application to exit immersive mode. The same is true when I show an Alert from my forms application.
Ideally I would want my application to stay in immersive mode all the time, at least when focus on Entry is requested (soft keyboard is not "shown" at all or immersive mode is not disabled when keyboard is "shown"). For Alerts I would like the application to reenter immersive mode when Alert is hidden. Currently I solved this by extending the Page class with custom DisplayAlert methos, which toggles immersive mode after DisplayAlert Task is completed.
I did some research and found the following articles:
Immersive mode while using keyboard
Appereantly user managed to solve the issue, so there could be a solution?
https://forums.xamarin.com/discussion/33034/prevent-entry-soft-keyboard-from-showing-on-android
But this solution does not work on Entry elements, and I would like to avoid writing custom renderers for elements.
Is there someone that faced a similiar issue before and managed to solve it?
It's not the best solution but defiantly the most simple for me.
Try this:
final Handler forceImmersive = new Handler();
Runnable runnable = new Runnable() {
#Override
public void run() {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
forceImmersive.postDelayed(this, 1000);
}
};
forceImmersive.postDelayed(runnable, 1000);

Get soft keyboard height in fullscreen mode

I have a fullscreen activity in which I have some editing area. For Android 4.3 and before, I set fullscreen mode with
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
In the editing view, I use the method described here to get notified when the soft keyboard visibility changes and also to get its height. Everything works fine.
From 4.4, in order to profit immersive mode, the normal mode is set (when status bar is visible) with:
activity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
But apparently, the method mentioned above to get soft keyboard height is no longer working with getWindowVisibleFrame() returns always the same rectangle whether the keyboard is visible or not.
Here my question: is there any other way to get soft keyboard state and its height on 4.4 that works with SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN?
Thanks in advance.

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.

android full screen mode(ICS), first touch shows the navigation bar

In my video play app, I use this flag: SYSTEM_UI_FLAG_HIDE_NAVIGATION to make the navigation bar disappear, but when I touch the screen, the navigation bar appears, after the first touch, my touch events and other events work fine.
My question is how can I take over the first touch?
You can't really take over the first event. You could implement View.OnSystemUiVisibilityChangeListener and be notified when the navigation bar is shown or hidden again, and then depending on its current state do what you wanted on the first touch, if possible.
However, there is no way you can completely take over the first touch, as stated in the documentation for SYSTEM_UI_FLAG_HIDE_NAVIGATION:
There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately. When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will be cleared automatically, so that both elements reappear at the same time.
For anyone coming across this post, if your intention is to hide the navigation/status bar and not have it come back up when you touch the screen, take a look at the different "immersive" configurations as described here: https://developer.android.com/training/system-ui/immersive
for example:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
That would effectively put your screen in "Full Screen" Mode regardless of any interaction the user has with the screen
To show the navigation/status bar again, simply change it back to:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE

Notification Bar visibility

My application is running landscape mode and I have set the following property of activity in manifest file
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
It surely hides the notification bar when my activity is running. But when for suppose I launch browser activity from my app and returns, the notification bar is visible again. I am trying to find its solution nothing is working. I followed the following link but in vain.
Hidden notification bar reappearing after screen lock and unlock
Any idea?
I handle these things in my java code
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
The nice part of handling this in java is you can release those flags at any time to get rid of full screen. I put this before setContent but I can't recall if that it required or not.
If this doesn't keep it fullscreen you could try to put it in the onResume(), which is my guess how your losing it.

Categories

Resources