Starting with API 14 you can use this flag SYSTEM_UI_FLAG_HIDE_NAVIGATION
on a View within your Activity to tell the system you want to hide the navigation bar until there is user interaction (screen touch). Once the user taps the screen the bar is shown.
The Activity that I am doing this in takes some action (starts a separate activity) when the user touches the screen, before adding the above flag to my view this worked perfectly.
After adding that flag the system intercepts the first screen touch and reacts to it by showing the nav bar. It's not until the second touch that any of my Views, or my Activity are receiving a TouchEvents.
Does anyone know of a way that I can set up a listener that will let me launch my second activity the first time the screen is touched instead of needing to double tap when using this hide nav flag?
I've tried all of the following and I'm not getting callbacks to any of them when the screen is touched for the first time to show the nav bar.
@Override
public void onUserInteraction(){
Log.i(myTag, "INTERACT");
}
@Override
public boolean onGenericMotionEvent(MotionEvent me){
Log.i(myTag, "GENERIC");
return true;
}
//I thought maybe the size change would lead to a callback here. No dice though.
@Override
public void onWindowAttributesChanged(WindowManager.LayoutParams params){
Log.i(myTag, "WINDOW CHANGE");
}
@Override
public boolean dispatchTouchEvent(MotionEvent me){
Log.i(myTag, "TOUCH");
return true;
}
Note: I am not trying to prevent the nav bar from being shown upon the first touch, I just want to also take some other action when that event occurs.