GDK - keep screen from dimming on a live card

2019-02-10 14:55发布

I have a high frequency live card published and I would like to keep the screen from dimming when the user is looking at the card.

I realize that this is a duplicate question to this one

GDK / APK for Google Glass - Keep screen from dimming

but the answer seems to no longer work. The sample projects don't stay on screen anymore either. I have also tried acquiring the wake lock without success.

Is there a way to keep the screen on?

3条回答
放荡不羁爱自由
2楼-- · 2019-02-10 15:06

The answer from the question you linked is for Immersion. When using a LiveCard, there is no way to get a wake lock as Glass is taking care of this: this is actually one of the main benefit of a LiveCard, keeping a long running application while Glass takes care of the screen.

If you want the user to be fully immersed in your app while using it, you should go with the Immersion pattern as this will give you full control other the screen.

查看更多
【Aperson】
3楼-- · 2019-02-10 15:25

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:

<uses-permission android:name="android.permission.WAKE_LOCK" />
查看更多
劳资没心,怎么记你
4楼-- · 2019-02-10 15:30

Or you can create your own simple app that changes the screen timeout value.

//change screen timeout to 60 min
    android.provider.Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 600000);

And you also need to specify some permissions:

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>

Using this I was able to keep my screen awake no matter if I was into an application or visualizing the live cards. At least for my 19.1 version of Glass

查看更多
登录 后发表回答