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?
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.
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
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" />