call to OpenGL ES API with no current context (logged once per thread)

what is the primary cause of this problem

Could you please describe the engine version and how to reproduce it?

@zhangxm
(cocos2d-x-2.2.2) this is the version that I am using.

const char * HelloWorld::addImage(){

JavaVM jvm; //this is important to avoid threading errors
thisEnv->GetJavaVM(&jvm); //this is important to avoid threading errors
jvm->AttachCurrentThread(&thisEnv, 0); //this is important to avoid threading errors
//jstring jstr = thisEnv->NewStringUTF(“From jni”);
jclass cls = thisEnv->GetObjectClass(thisObj);
jmethodID method = thisEnv->GetMethodID(cls, “getPath”,"()Ljava/lang/String;");
jstring result = (jstring)thisEnv->CallObjectMethod(thisObj, method);
// call the sayHello() method
const char * string=thisEnv->GetStringUTFChars(result, 0);
//CCMessageBox(string,“Alert”);
//if(string!=NULL){
CCSprite person = CCSprite::create(string);
//person->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
person->setAnchorPoint(ccp(0, -.75));
person->setPosition(ccp(0,0));
this->addChild(person,204);

return string;

}
and calling the function above inside of AppDelegate::applicationWillEnterForeground will cause that error…help me please

Don’t call it in AppDelegate::applicationWillEnterForeground. Because OpenGL context will be lost when enter to background. At this time OpenGL context may not be re-create by Android system. So, please do the operation after it is totally enter foreground.

@zhangxm

I need to call the function above after the user take a picture so that the captured picture will be used as a sprite. How can I do it after it is totally enter foreground? I really need your help please.

For example, you can use schedule to delay some time.

you mean scheduler? what i tried is like this

HelloWord hello;
hello.schedulOnce(schedule_select(hello.loadImage),3.0f);
I am calling this inside of AppDelegate::ApplicationWillEnterForeground

but putting the above code has no effect.

CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: 0.0000 to 0.0000
I got this message when executing the code

It seems it takes more than 3 seconds for entering to foreground. How about set a long time.

@zhangxm
Sir i tried this->scheduleOnce(schedule_selector(HelloWorld::displayImage), 3.0f); putting it inside of HelloWorld init() function and it executed after 3 seconds

but when I call it inside of appdelegate there is no effect, is scheduleOnce applicable inside of appdelegate class?

CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(HelloWorld::displayImage), this , 5, false, 0, 0 );

using the above code, the function will be successfully executed within the specified delay time but the problem is the sprite will not display…there is no error produced

Does it have problem if you invoke these codes in other place?

I have the same problem could you help me ? my email qzzzzq@sina.cn If you are willing to help me
by the way are you Chinese ?