2

I am receiving a message using the MessageApi. I now need to wake the wearable's screen programmatically from the onMessageReceived() event. How do I do this?

I've tried using PowerManager with this code:

PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);
wakeLock.acquire();

which does nothing to wake the watchface

Cœur
  • 37,241
  • 25
  • 195
  • 267
Timmo
  • 2,266
  • 4
  • 34
  • 54
  • Go through this:- https://developer.android.com/training/scheduling/wakelock.html – Ram Prakash Bhat Aug 29 '16 at 13:33
  • Thanks, but how do I apply this to a watchface service in the `onMessageReceived` event? – Timmo Aug 29 '16 at 13:46
  • The code you need is in the link that Ram posted. You'll use the snippet from the second section (Keep the CPU on), but to turn on the screen on you'll use the PowerManager.SCREEN_BRIGHT_WAKE_LOCK constant. – Sterling Aug 29 '16 at 21:34
  • I've just tried this with no end. See edit above – Timmo Sep 24 '16 at 20:23

0 Answers0