Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android 4.0 Navigation Bar hijack first touch event

In Android 4.0 on devices without hardware navigation keys, Android will render navigation bar.

You can hide it, if you want by using setSystemUiVisibility().

If that is done, lets say if you want to get as much screen as possible for playback, when you first touch screen (and yes, on View you implement View.onTouchEvent()), first touch will be hijacked by Android and your API will not be called. Only once navigation bar is visible it will be called.

Now, that can be avoided by also listening to:

http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html

and when navigation bar is visible just do what you will do on first touch.

Is there any other way to do the same, that will say Android 4.0 to propagate touch event to my app once Navigation bar is done with it?

like image 210
Perun Avatar asked Nov 23 '11 02:11

Perun


1 Answers

No, the system always consumes the first touch that brings the navigation bar back. You should only hide the navigation bar if your app is in a non-interactive state such as video playback.

like image 100
adamp Avatar answered Oct 17 '22 05:10

adamp