-1

I'm working with Xamarin.Forms and I need some help.

Regarding the OnResume event, how can I know what I need to reload?

I ask this because sometimes everything resumes OK but other times the configuration files don't reload correctly.

Does any method exist to reload entire app when onresume is fired? like a game which loads everything each time.

Thanks!

Mouse On Mars
  • 1,086
  • 9
  • 28
Uraitz
  • 476
  • 4
  • 12
  • 2
    That is a rather vague question. You should know / detect what services need reloading, for example if you are making https calls or Sockets, you should disconnect and then reconnect. But without knowing the whole picture, it's hard to help you. – Bruno Caceiro Jun 25 '19 at 09:47
  • are you doing a api call? if yes i can help you i did a lot of that – R4y Jun 25 '19 at 09:51
  • read up more on app lifecycle - it's tad different on iOS and Android. There are graphs in docs showing every possible chain of lifecycle events, maybe this will help you find the one that your app does not support correctly – Krzysztof Skowronek Jun 25 '19 at 10:03
  • @BrunoCaceiro OnResume, I want to load last content page and reload it's configuration file. Sometimes just options and other times are list items or user configuration. No sockets, no api calls. – Uraitz Jun 25 '19 at 10:44
  • 1
    @Uraitz When the app resumes from background state to the foreground, the `OnResume` will be called. The application will automatically load the last page without any extra settings. But if the application has been in the background state for too long, it will go to the quit state. Then it will reload the configuration and start from the initial page. So it depends on which configuration you want to load. You can record the information to the disk then retrieve it when the app comes into the active state. – Ax1le Jun 26 '19 at 08:13
  • Thanks @LandLu-MSFT last question, when application loads page without any extra settings. What is the execution order? OnResume event, page constructor, page onappearing. Should i create event to update current page after onresume has finished? – Uraitz Jun 27 '19 at 06:57
  • 1
    @Uraitz `OnResume` will be called as the application's lifecycle. But the current page's lifecycle event won't be triggered. You can test this conclusion on your side. – Ax1le Jun 27 '19 at 07:15

1 Answers1

-1

i got a code where a function get called every 1.3 seconds

Device.StartTimer(TimeSpan.FromSeconds(1.3), () =>
        {
            Device.BeginInvokeOnMainThread(yourFunction);

            return true;
        });
}
Ru Chern Chong
  • 3,692
  • 13
  • 33
  • 43
R4y
  • 315
  • 1
  • 5
  • 14
  • you have just to add your function that you want to refresh in the place where i typed yourFunction – R4y Jun 25 '19 at 10:46
  • This is not what I need, I have the fire event, OnResume, I don't need to generate more events, I need to know what objects i need to reload when event is fired. – Uraitz Jun 25 '19 at 10:51
  • i can't understand what you mean – R4y Jun 28 '19 at 09:39