GDK / APK for Google Glass - Keep screen from dimming

后端 未结 2 549
轮回少年
轮回少年 2020-12-29 23:26

What part of the code in the four sample APK projects listed here for Google Glass prevents the screen from dimming?

When I write my own APK and sideload it, after t

2条回答
  •  清歌不尽
    2020-12-29 23:50

    The only way that worked for me was by acquiring a wakeLock:

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK , TAG);
    wakeLock.acquire(WAKE_LOCK_DURATION_IN_MILLIS);
    

    You also need a permission for that:

    
    

提交回复
热议问题