我正在尝试在Android Wear手表进入环境模式之前触发一些动作。对于活动,有onEnterAmbient() overrideable方法,但我认为墙纸服务不是这样的。
那么,有没有办法在手表进入环境模式之前触发它的动作呢?
编辑:具体地说,我会检测屏幕何时开始变暗,就在环境模式有效触发之前。
发布于 2015-07-23 03:31:42
编辑过的。
在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();
}
https://stackoverflow.com/questions/31572129
复制相似问题