How to tell when an Android wristwatch face will enter environment mode?

I am trying to activate some actions on the front of Android Wear before going into Ambient mode. There is an overridden onEnterAmbient () method for actions , but I believe this is not the case for wallpaper services.

So, is there a way to initiate actions on the watch face before entering Ambient Mode?

EDIT: Especially, I'd like to detect when the screen starts to dim, right before the environment effect is triggered effectively.

+3


source to share


1 answer


Ed.

In 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();
}

      

+2


source







All Articles