3

I am trying to trigger some actions on an Android Wear watch face right before it goes into Ambient Mode. For activities, there is the onEnterAmbient() overrideable method, but I believe this is not the case for wallpaper services.

So, is there any way to trigger actions on a watch face right before it enters Ambient Mode?

EDIT: Especificaly, I would be looking to detect when the screen starts going dim, right before ambient mode effectively triggering.

1 Answers1

2

Edited.

On the CanvasWatchFaceService:

private boolean firstAnimation;     

@Override
public void onAmbientModeChanged(boolean inAmbientMode) {
  super.onAmbientModeChanged(inAmbientMode);
  if(inAmbientMode){
    firstAnimation = false;
  }
  invalidate();        
}

@Override
public void onDraw(Canvas canvas, Rect bounds) {
  if(inAmbientMode){
    if(firstAnimation){
    // draw ambient mode
    }else{
    //draw animation and when finish the animation
    //set the firstAnimation flag to true
    }
  }else{
    //draw normal mode
  }
  invalidate();
}
Vinicius DSL
  • 1,839
  • 1
  • 18
  • 26
  • Thanks Vinicius, but I am looking at doing some short animation before drawing the first onAmbiet frame. Especifically, I wish to detect when the screen starts getting dim, before ambient mode actally triggering. – GarciadelCastillo Jul 22 '15 at 19:36
  • Maybe using a flag, so you have an animationFlag on false when the face enter on ambient mode, draw one time the animation and them put it to true, and draw the ambient mode face if(inAmbientMode && animationFlag) this because each time invalidate() method is called, the face is draw. – Vinicius DSL Jul 22 '15 at 19:43