private static AppActivity app = null; @Override public Cocos2dxGLSurfaceView onCreateView() { Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); // TestCpp should create stencil buffer glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); app = this; return glSurfaceView; }
public static void setIdleTimer(final boolean idleFlag) { Log.i(TAG, "setIdleTimer:" + idleFlag); //这里一定要使用runOnUiThread app.runOnUiThread(new Runnable() { @Override public void run() { if (idleFlag) { Log.i(TAG, "setIdleTimer1:" + idleFlag); //wakeLock.acquire(); app.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Log.i(TAG, "setIdleTimer11:" + idleFlag); } else { Log.i(TAG, "setIdleTimer2:" + idleFlag); app.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Log.i(TAG, "setIdleTimer22:" + idleFlag); //wakeLock.release(); } } }); }
时间: 2024-10-05 19:10:35