Search code examples
androidcocos2d-android

Cocos2d UI does not show up in Samsung S4


I have an app with an UI based on cocos2d (https://code.google.com/p/cocos2d-android-1/) which works very well on some phones, but on others only black screen is shown with an ad on the bottom. When the black screen shows up, I am still able to use the app if I know where to press for a particular button (but obviously I don't see anything on the screen, just know that the buttons work).

example: S4 with SDK 4.3 - black screen and only ad shows on the bottom, the controls still work, so if you blindly know where to press, the app will do what it is designed to do

S3 with SDK 4.3 - app works fine with ad at the bottom

Galaxy Trend with SDK 4.0.4 - app works fine with ad at the bottom

If in my manifest I change uses-sdk to be empty (not defining any sdks), the app works fine on S4. This is obviously not ideal, but interesting that it works.

I first thought it was related to the ad overlaying the UI content, but after removing the ad, the behavior is the same. I see only black screen, but can control the app by pressing in the places where the buttons should be.

I am happy to supply more info or code samples, but at this stage, I have no idea what would be need to troubleshoot this. Anybody ran into this before? thank you in advance

EDIT: here is the code I am using:

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        mGLSurfaceView = new CCGLSurfaceView(this);
        setContentView(mGLSurfaceView);

        Context context = CCDirector.sharedDirector().getActivity().getBaseContext();          
        g.sv = new SurfaceView(context);
        g.sv.setLayoutParams(new LayoutParams(1, 1) );
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1);
        addContentView(g.sv, params);

Solution

  • I recently had a similar problem. When I launch the app on a avd with KitKat (SDK 4.4.2) me black screen appeared. Watch these links one is a case of Stackoverflow with code that corrects this problem and the other is a bond issue open for this problem. I hope it helps.

    Black Screen on Android Launch Unless using Landscape Orientation

    https://github.com/ZhouWeikuan/cocos2d/issues/65