4

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?

Community
  • 1
  • 1
Jakub K
  • 1,713
  • 1
  • 13
  • 21

3 Answers3

4

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.

Alain
  • 6,044
  • 21
  • 27
  • In the question I referenced they mentioned that the sample apps (Stopwatch, Compass) use the solution to keep the screen on. Right now the sample apps are made as live cards, does it mean that back then they were made as immersions? – Jakub K Jan 30 '14 at 18:57
  • That is correct, the initial Compass sample was using an Activity but switched to using a LiveCard when the sneak peek of the GDK launched. This [commit](https://github.com/googleglass/gdk-compass-sample/commit/28451a8c0a36457e03fdb0e0646f18385a7ce9c2) shows the changes made to move the Compass from a regular app to a Glassware using the GDK. – Alain Jan 30 '14 at 23:43
  • Thank you. Do you know if there are any plans to add this possibility to live cards in the future or does that go against the design? – Jakub K Jan 31 '14 at 08:35
  • look at this Question. it might help http://stackoverflow.com/questions/21450077/what-is-androidimmersive-attribute-in-android-manifest-file/21450719?noredirect=1#comment32378613_21450719 – Sheraz Ahmad Khilji Jan 31 '14 at 12:43
  • 2
    @jacovac this behavior is actually part of the design as this helps users and developers save as much battery life as possible by keeping the screen off when not needed. Please feel free to file a feature request on our [issue tracker](https://code.google.com/p/google-glass-api/issues/list) and explain your use-case. – Alain Jan 31 '14 at 17:08
1

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

Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54
-1

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" />
Manuel M
  • 809
  • 1
  • 10
  • 25