Something that worked well for me - hopefully this will help those who come back to this in the future.
You can use a Handler to change the flags after the overflow menu appears. On my devices, the back button still appears but the black navigation bar is not visible (Disappears before it appears visibly).
// Creates the PopupMenu.
PopupMenu popup = new PopupMenu(getContext(), view)
{
@Override
public void show()
{
// Shows the menu.
super.show();
// Sets the UI flags to prevent weird changing of window.
Handler temp = new Handler();
temp.postDelayed(new Runnable()
{
@Override
public void run()
{
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}, 50);
}
}