Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17093

Cocos2d-x Android Immersive mode setup instruction

$
0
0

@energyy wrote:

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

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;
}

2) 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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17093

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>