@Jesus said
>> yes, but that works only with the new(under development) version of cocos2dx, that changes a lot of namespaces, so it will be really hard to apply to current or previous versions of cocos2dx…
I downloaded cocos2d-x-2.1.4 and ported the same code, with the result of now having the black screen (though the game keeps working: I know because sound is still active). I’ve tried many of the proposed solutions in this thread, but still nothing. If anyone has any other suggestion, please let me know.
I’m experiencing the same issue.
When events occur in Cocos2dxActivity:
onPause ~~> onResume: it works great.
onPause~~> onCreate: black screen when returning to game. (eg change the system language)
P.S.
I used the bad code, but it helps me:
(./cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java)
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if (sContext != null)
{
// restart the application when it is re-created Activiti
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
Cocos2dxHelper.terminateProcess();
}
sContext = this;
this.mHandler = new Cocos2dxHandler(this);
this.init();
Cocos2dxHelper.init(this, this);
}
I found out how to reproduce the black screen issue after sleep in my case:
when I start the app with the command “adb shell am start n" it goes black after waking from sleep
when I start the app with the command "adb shell am startS” or directly from the app browser everything is fine
in both cases I forced the app to stop before executing the command
I’m using cocos2d-x-2.1.4 btw without any of the fixes from this thread
[…]
>
P.S.
I used the bad code, but it helps me:
(./cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java)
[…]
Hi, Denis. I tried your code, and the result is that the phone doesn’t go back to the game after waking up, and when getting manually back to the game, it restarts. Even though this is some kind of solution, it’s not what I’m looking for.
I found out how to reproduce the black screen issue after sleep in my case:
>
when I start the app with the command “adb shell am start n" it goes black after waking from sleep
>
when I start the app with the command "adb shell am startS” or directly from the app browser everything is fine
>
in both cases I forced the app to stop before executing the command
>
I’m using cocos2d-x-2.1.4 btw without any of the fixes from this thread
Hi, Victor.
Thank you for the information. I’m not really sure what those commands do, but searching in Android Developers it says that:
"S: Force stop the target app before starting the activity."
I couldn’t find then option for the start command.
So what you are saying is that the problem may be because of the way the app is created and/or sent to the phone? If so, is there anything I could do from Eclipse to solve it?
Hi Pablo,
I’m sorry I can’t answer your questions, but did you try to kill the app in the Android app browser and start it again, without using Eclipse?
Hi Pablo,
I’m sorry I can’t answer your questions, but did you try to kill the app in the Android app browser and start it again, without using Eclipse?
REMOVE THE ** TARGETSDKVERSION IN THE ANDROID MANIFEST.
That’s it. I had “android:targetSdkVersion=”14" in my manifest. Got rid of it and DONE, the problem is absolutely gone.
So, to anyone still having this problem, try NOT specifying the target SDK in the manifest. I still have minsdk and maxsdk, but targetsdk? Get rid of that shit and you’ll have NO black screen after waking up the device.
Thanks Victor and everyone else for your answers! ^^
PS: It would be nice to know WHY this worked, but I think understanding it by myself is kind of out of my reach. To any person working on the framework, if you can shed some light on this, it would be awesome. Now, back to coding a game for me.
If choice Android build target >= Android 4.0 (API Level >= 14), the black screen will happen every time on many device (Not all devices).
I change to Android 2.3.3 (API Level 10) then it run will.
I will download all API, and try which version’s API will make the black screen bug happen.
As we need the new functions supported by new version Android API, please you wonderful guys fix this bug
REMOVE THE ** TARGETSDKVERSION IN THE ANDROID MANIFEST.
That’s it. I had “android:targetSdkVersion=”14" in my manifest. Got rid of it and DONE, the problem is absolutely gone.
Yes, I updated to 2.1.4 last week and had the same problem. After removing my “android:targetSdkVersion=”14" line it has gone away most of the time, but not 100%. The last version of Arrow Mania was using Cocos2d-x 2.0.2 and didn’t have this issue at all.
Ok, so in our case, this worked out:
in AndroidManifest.xml, add this:
>
android:configChanges=“orientation|screenSize|smallestScreenSize”
>
to your Cocos2D-X activity.
>
This solved our particular problem on Kindle Fire HD 8.9 and Nexus 7. I hope this helps anyone.
Thanks for this! This fixed the black screen issue coming from lock screen.
We’ve added this code in Cocos2dxGLSurfaceView.java
>
[…]
>
Seems to fix most of the problems related to this issue.
Thank you for your help, Mircea…
I tried, But it’s not work.
I use HTC new one for test, Cocos2d-x-2.1.4, Android API Level 14 (4.0.3)
I think I can only change back to the API Level 8 or 9 right now.
If there aren’t any problems, we will release v2.1.5 which just resolves critical bugs.
Thanks.
Jesus Bosch wrote:
Minggo Zhang wrote:
> It is fixed in this pull request.
>
yes, but that works only with the new(under development) version of cocos2dx, that changes a lot of namespaces, so it will be really hard to apply to current or previous versions of cocos2dx…
Hi all, I fixed this issue based on v2.1.4. The Pull Request is here https://github.com/cocos2d/cocos2d-x/pull/3450 .
Could you test it and give me the feedback?
>
If there aren’t any problems, we will release v2.1.5 which just resolves critical bugs.
Thanks.
>
Jesus Bosch wrote:
> Minggo Zhang wrote:
> > It is fixed in this pull request.
>
> yes, but that works only with the new(under development) version of cocos2dx, that changes a lot of namespaces, so it will be really hard to apply to current or previous versions of cocos2dx…
Dear James…
Thank you for fix the bug, I try it asap, but some error in Android…
CCTexture2D.cpp:518:55: error: ‘dimensions’ was not declared in this scope
CCTexture2D.cpp:518:67: error: ‘hAlignment’ was not declared in this scope
CCTexture2D.cpp:518:79: error: ‘vAlignment’ was not declared in this scope
CCTexture2D.cpp:518:91: error: ‘fontName’ was not declared in this scope
CCTexture2D.cpp:518:101: error: ‘fontSize’ was not declared in this scope
I think the problem is this function…
bool CCTexture2D::initWithString(const char text, ccFontDefinitiontextDefinition)
{ #if (CC_TARGET_PLATFORM CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM CC_PLATFORM_IOS)
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); #endif
:
:
}
The Pull Request have not been merged, so you have to pull my branch to test.
Atwood Yen wrote:
James Chen wrote:
> Hi all, I fixed this issue based on v2.1.4. The Pull Request is here https://github.com/cocos2d/cocos2d-x/pull/3450 .
> Could you test it and give me the feedback?
>
> If there aren’t any problems, we will release v2.1.5 which just resolves critical bugs.
> Thanks.
>
> Jesus Bosch wrote:
> > Minggo Zhang wrote:
> > > It is fixed in this pull request.
> >
> > yes, but that works only with the new(under development) version of cocos2dx, that changes a lot of namespaces, so it will be really hard to apply to current or previous versions of cocos2dx…
>
Dear James…
>
Thank you for fix the bug, I try it asap, but some error in Android…
CCTexture2D.cpp:518:55: error: ‘dimensions’ was not declared in this scope
CCTexture2D.cpp:518:67: error: ‘hAlignment’ was not declared in this scope
CCTexture2D.cpp:518:79: error: ‘vAlignment’ was not declared in this scope
CCTexture2D.cpp:518:91: error: ‘fontName’ was not declared in this scope
CCTexture2D.cpp:518:101: error: ‘fontSize’ was not declared in this scope
>
I think the problem is this function…
bool CCTexture2D::initWithString(const char text, ccFontDefinitiontextDefinition)
{ #if (CC_TARGET_PLATFORM CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM CC_PLATFORM_IOS)
> #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); #endif
:
:
}
>
Best Regard