Repository: AvaloniaUI/Avalonia
File: src/Android/Avalonia.Android/AvaloniaView.cs (C#)

Code before:
                OnVisibilityChanged(true);
            }
        }

        internal TopLevelImpl TopLevelImpl => _view;
        internal TopLevel? TopLevel => _root;

        public object? Content
        {
            get { return _root.Content; }
            set { _root.Content = value; }
        }

        internal new void Dispose()
        {
            OnVisibilityChanged(false);
            _surfaceCreated = false;
            _root?.Dispose();
            _root = null!;
        }

        public override bool DispatchKeyEvent(KeyEvent? e)
        {
            if (!base.DispatchKeyEvent(e))
                return _view.View.DispatchKeyEvent(e);
            return true;
        }

        [SupportedOSPlatform("android24.0")]
        public override void OnVisibilityAggregated(bool isVisible)
        {
            base.OnVisibilityAggregated(isVisible);
            OnVisibilityChanged(isVisible);
        }

        protected override void OnVisibilityChanged(View changedView, [GeneratedEnum] ViewStates visibility)
        {
            base.OnVisibilityChanged(changedView, visibility);
            OnVisibilityChanged(visibility == ViewStates.Visible);
        }

        internal void OnVisibilityChanged(bool isVisible)
        {
            if (_root == null || !_surfaceCreated)
                return;
            if (isVisible && _timerSubscription == null)
            {
                if (AvaloniaLocator.Current.GetService<IRenderTimer>() is ChoreographerTimer timer)
                {
                    _timerSubscription = timer.SubscribeView(this);
                }

Review comment (suggestion):
Shouldn't it be the other way around? Like we do on other platforms most of the time.

I.e., try to handle it on the Avalonia side, and if not handled - call base implementation.

```suggestion
            if (!_view.View.DispatchKeyEvent(e))
                return base.DispatchKeyEvent(e);
            return true;
```

Code after:
                OnVisibilityChanged(true);
            }
        }

        internal TopLevelImpl TopLevelImpl => _view;
        internal TopLevel? TopLevel => _root;

        public object? Content
        {
            get { return _root.Content; }
            set { _root.Content = value; }
        }

        internal new void Dispose()
        {
            OnVisibilityChanged(false);
            _surfaceCreated = false;
            _root?.Dispose();
            _root = null!;
        }

        public override bool DispatchKeyEvent(KeyEvent? e)
        {
            if (!_view.View.DispatchKeyEvent(e))
                return base.DispatchKeyEvent(e);
            return true;
        }

        [SupportedOSPlatform("android24.0")]
        public override void OnVisibilityAggregated(bool isVisible)
        {
            base.OnVisibilityAggregated(isVisible);
            OnVisibilityChanged(isVisible);
        }

        protected override void OnVisibilityChanged(View changedView, [GeneratedEnum] ViewStates visibility)
        {
            base.OnVisibilityChanged(changedView, visibility);
            OnVisibilityChanged(visibility == ViewStates.Visible);
        }

        internal void OnVisibilityChanged(bool isVisible)
        {
            if (_root == null || !_surfaceCreated)
                return;
            if (isVisible && _timerSubscription == null)
            {
                if (AvaloniaLocator.Current.GetService<IRenderTimer>() is ChoreographerTimer timer)
                {
                    _timerSubscription = timer.SubscribeView(this);
                }