@Override
    public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
        switch (event) {
            case ON_DESTROY:
                // activity is off the foreground stack
                // activity is being destructed completely as a result of Activity#finish()
                // this is a killable automata state!
                jmeSurfaceViewLogger.log(Level.INFO, "Hosting Activity has been destructed.");
                break;
            case ON_PAUSE:
                // activity is still on the foreground stack but not
                // on the topmost level or before transition to stopped/hidden or destroyed state
                // as a result of dispatch to Activity#finish()
                // activity is no longer visible and is out of foreground
                if (((Activity) getContext()).isFinishing()) {
                    if (destructionPolicy == DestructionPolicy.DESTROY_WHEN_FINISH) {
                        legacyApplication.stop(!isGLThreadPaused());
                    } else if (destructionPolicy == DestructionPolicy.KEEP_WHEN_FINISH) {
                        jmeSurfaceViewLogger.log(Level.INFO, "Context stops, but game is still running.");
                    }
                } else {
                    loseFocus();
                }
                break;
            case ON_RESUME:
                // activity is back to the topmost of the
                // foreground stack
                gainFocus();
                break;
            case ON_STOP:
                // activity is out off the foreground stack or being destructed by a finishing dispatch
                // this is a killable automata state!
                break;
        }
    }
A state change observer to the holder Activity life cycle, used to keep this android view up-to-date with the holder activity life cycle.

@param source the life cycle source, aka the observable object.
@param event  the fired event by the observable object, which is dispatched and sent to the observers.
jme3-android/src/main/java/com/jme3/view/surfaceview/JmeSurfaceView.java