zoukankan      html  css  js  c++  java
  • 安卓屏幕常亮不锁屏

    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(); 
                     }
                 }
             });
         }   
  • 相关阅读:
    如何保持页脚始终在页面底部
    CSS自适应宽度圆角按钮
    ACM1004
    java输出格式
    北大ACM1001题Exponentiation(求高精度幂)
    深入理解sizeof
    java之类BigDecimal
    ACM1003
    ACM1005
    C的输出格式printf
  • 原文地址:https://www.cnblogs.com/pengyingh/p/4898474.html
Copyright © 2011-2022 走看看