Search code examples
androidxamarinxamarin.androidonresume

How to control to do events or not in OnResume()?


 protected override void OnResume()
    {
        base.OnResume();
        //if the page comes from another Activity, don't need to do ShowCurrentPage() to refresh page 
        //if I press the home button, then the page comes from home page , need to  do ShowCurrentPage() to refresh page 
        ShowCurrentPage();
    }

what my question is, how to distinguish the origin from home page or Activity when I do the OnResume() to show Activity ?

And if I need to do different event in OnResume() according to different origin of Activity, if I must write if{} before ShowCurrentPage()

Wating for good answers, Thank you!


Solution

  • Xamarin Forms : Use Plugin.Settings to store value as local data in your device, base on this value to do ShowCurrentPage() method or not. As when page comes from home page, set value in OnStop()

    Native apps : Use sharedpreferences...