In my Android app I want to switch activities from my renderer. When I create the Renderer I pass context in the constructor. In my Renderer in the onDrawFrame function:
public MyRenderer(Context ctx){
this.context=ctx;
}
public void onDrawFrame(GL10 gl) {
testFlag = renderFrame();
if(testFlag > 0)
{
Intent myIntent = new Intent(this.context, MyActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.context.startActivity(myIntent);
testFlag = 0;
return;
}
}
This calls the onPause() in my main activity which handles some OpenGL staff..
What I get is an error when switching the acivities:
At that point I receive the following error:
call to OpenGL ES API with no current context ( logged once per thread)
Can anyone please help me? I realize that this is caused because a call to OpenGL is not made from the OpenGL thread but how do I fix it??
What is the proper way to switch activities from within the renderer?