我可以查看是否启用了老化保护属性,但有没有办法判断老化模式当前是否处于活动状态?特别是当屏幕移动时。
基本上类似“onAmbientModeChanged”用于刻录。
谢谢!
答案 0 :(得分:2)
在活动中,展开WearableActivity
并覆盖onEnterAmbientMode
,您可以在参数中找到一个可以检索所需属性的Bundle。
(查看此WearableActivity)
@Override
public void onEnterAmbient(Bundle ambientDetails) {
super.onEnterAmbient(ambientDetails);
boolean burnIn = ambientDetails.getBoolean(EXTRA_BURN_IN_PROTECTION);
boolean lowBit = ambientDetails.getBoolean(EXTRA_LOWBIT_AMBIENT);
}
在 CanvasWatchFaceService.Engine 中,覆盖onPropertiesChanged
:
@Override
public void onPropertiesChanged(Bundle properties) {
super.onPropertiesChanged(properties);
boolean lowBit = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
boolean burnIn = properties.getBoolean(PROPERTY_BURN_IN_PROTECTION, false);
}
覆盖onAmbientModeChanged(boolean inAMbientMode)
,只要表面从交互模式切换到环境模式,就会调用它,反之亦然:
@Override
public void onAmbientModeChanged(boolean inAmbientMode) {
super.onAmbientModeChanged(inAmbientMode);
if (mState.isAmbient() != inAmbientMode) {
mState.setAmbient(inAmbientMode);
//make your updates on your drawing parameters if needed
invalidate();
}
}