Listen for first TouchEvent when using SYSTEM_UI_FLAG_HIDE_NAVIGATION Listen for first TouchEvent when using SYSTEM_UI_FLAG_HIDE_NAVIGATION android android

Listen for first TouchEvent when using SYSTEM_UI_FLAG_HIDE_NAVIGATION


As Josh Lee suggested in his comment, View.OnSystemUiVisibilityChangeListener was the key.

Here is the code that I used:

mView.setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {    @Override    public void onSystemUiVisibilityChange(int vis) {        Log.i(myTag, "System UI"+ vis);        if(vis == 0){            Intent i = new Intent(MainActivity.this, AnotherActivity.class);            startActivity(i);            finish();        }    }});

I think that mView could be a reference to any view that is currently showing in your Activity. In my case it was a fullscreen VideoView, and was the only view in my layout.