Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

how to pop an application to root view

$
0
0

Hi

I would like to have my Application show in the root view after it has been in the background for more than 5 min.
the following code gets called but nothing happens in the UI.

 public class App : Application
    {
        public static App Instance;
        private HomeView _HomePage;
        private DateTimeOffset _TimeWentToBack;
        public App(AppSetup setup)
        {
            Instance = this;
            _HomePage = AppContainer.Container.Resolve<HomeView>();

            MainPage = new CustomNavigationPage(_HomePage.GetMainPage())
            {
            };
        }

        public async void ClearNavigationAndGoToOverviewPageAsync()
        {
            var nav = MainPage.Navigation;
            await nav.PopToRootAsync();

        }

        protected override void OnStart()
        {
        }

        protected override void OnSleep()
        {
            _TimeWentToBack = DateTimeOffset.Now;
        }

        protected override void OnResume()
        {
            base.OnResume();
            TimeSpan timeSinceLastOpen = DateTimeOffset.Now - _TimeWentToBack;
            if (timeSinceLastOpen.TotalMinutes >= 5)
            {
                ClearNavigationAndGoToOverviewPageAsync();
                _HomePage.ReloadData();
            }
        }
    }

Thanks HP


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>