Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when android wear watch face is going to enter ambient mode?

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.

like image 383
GarciadelCastillo Avatar asked Dec 05 '25 04:12

GarciadelCastillo


1 Answers

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();
}
like image 130
Vinicius DSL Avatar answered Dec 06 '25 22:12

Vinicius DSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!