2

I need to disable/enable screen dimming from NativeActivity (when rendering is performed by OpenGL). I have inherited MyNativeActivity:

public class MyNativeActivity extends NativeActivity {
    public final void disableAutoSleep()
    {
        Log.d("TWP", "disableAutoSleep()...");
        runOnUiThread(new Runnable() {          
            @Override
            public void run()
            {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
        });
    }
}

And then I call this method from my native code using JNI. What I see in LogCat is:

06-03 16:51:26.964: D/TWP(2531): disableAutoSleep()...
06-03 16:51:27.034: E/BufferQueue(125): [com.example.MyNativeActivity]
    dequeueBuffer: SurfaceTexture has been abandoned!
06-03 16:51:27.034: W/nvwsi(2531): dequeueBuffer failed, error -19

and then glGetError() (in my rendering routine) returns GL_INVALID_FRAMEBUFFER_OPERATION and screen becomes black.

It seems that Android terminates or recreates my drawing window in response to getWindow().addFlags(...). But I do not get any notifications in engine_handle_cmd (that is main C++ message callback in native activity). How do I handle it or what am I doing wrong?

Update

I tried

ANativeActivity_setWindowFlags(state->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0);

but also resulted in

06-03 18:34:47.054: E/BufferQueue(125): [com.example.MyNativeActivity] dequeueBuffer: SurfaceTexture has been abandoned!
Nick
  • 3,205
  • 9
  • 57
  • 108

0 Answers0