I am trying to make a snake game. I've been testing the game on my nexus 4 which has it's back /home buttons as touch buttons so when I wanted to full screen activity the touch buttons would appear over the activity so to remove them I use the following code :
view.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);
But when I tested the game on my friend's sony ericson phone which has hardware buttons. So on his phone the bottom edge of the screen extends more towards the area behind the buttons. How do i fix that?
This is how i'm getting the screen size :
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height = metrics.heightPixels;
width = metrics.widthPixels;