Google updated how ambient mode works in WearOS but I'm having trouble implementing the changes.
This is the change they made: https://android-review.googlesource.com/c/platform/frameworks/support/+/2534423
Rename AmbientLifecycleObserverInterface -> AmbientLifecycleObserver
The problem is I'm now getting this error message:
'AmbientLifecycleObserver' is abstract; cannot be instantiated
My code looks exactly like the sample code they provide:
So I'm confused on what I'm doing wrong. This is the code for AmbientLifecycleObserver
:
This is my code:
private AmbientLifecycleObserver mAmbientLifecycleObserver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getting error 'AmbientLifecycleObserver' is abstract; cannot be instantiated
mAmbientLifecycleObserver = new AmbientLifecycleObserver(this, mAmbientCallback);
getLifecycle().addObserver(mAmbientLifecycleObserver);
}
final AmbientLifecycleObserver.AmbientLifecycleCallback mAmbientCallback = new AmbientLifecycleObserver.AmbientLifecycleCallback() {
@Override
public void onEnterAmbient(@NonNull AmbientLifecycleObserver.AmbientDetails ambientDetails) {
}
@Override
public void onUpdateAmbient() {
}
@Override
public void onExitAmbient() {
}
};