Cocos2d-x Android Immersive mode setup instruction

We spent some time making it work for cocos2d-x correctly. So now it works for us and should work for you!:slight_smile:

  1. Edit AppActivity.java

    @Override
    public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);
      hideSystemUI();
    

    }

…

 @TargetApi(Build.VERSION_CODES.KITKAT)
  private void hideSystemUI() {
             if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
                {
                    getWindow().getDecorView().setSystemUiVisibility(5894);
                    return;
                } else
                {
                    getWindow().getDecorView().setSystemUiVisibility(257);
                    return;
                }
   }

…

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    if (hasFocus){
        hideSystemUI();
    }
}

…

public Cocos2dxGLSurfaceView onCreateView()
{
    glSurfaceView = new Cocos2dxGLSurfaceView(this);
    glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);

    return glSurfaceView;
}
  1. Modify Androidmanifest.xml

     <activity android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:name="org.cocos2dx.cpp.AppActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateVisible|adjustResize">
    

android:windowSoftInputMode=“stateVisible|adjustResize” this part is required