'Xamarin:forms Application opening wrong page after device shutting down on low battery

I've been working with an application for my company that we use for the work in warehouse. We use android based devices for it, and we have faced a rare issue.

We do not have (yet) a device for everyone, so devices go from hand to hand. Each user has its own password mostly to ensure that two people cannot start the same job. As such, the jobs that are being done do not show for other users and even if one were to ask for a job, the device would first check for availability. If everything is right, the new page open with the job to do.

What we've seen is that in a few instances, a user managed to manipulate another's job. Everytime, using the only button to get out of an ongoing job, which also reset the job. We've looked for a while to realize that the user that where resetting these jobs never actually requested said job. So for some reason, they were able to enter a job that wasn't theirs, without asking the server.

Well one of them actually came with the answer: When the battery runs out, they usually quickly go charge it while taking a new device to finish their job. It's only hours later that the problem happen. When someone takes back the 1st device that had been left to recharge. They are greeted by the login screen, but upon login, instead of being sent to the menu page, it instantly load the data it had saved when the phone was low on battery. As a result, they are greeted with a job that isn't there with the only options to complete it (impossible because it's already completed) or reset it. Leading to some frustrating moments.

So here's my question: why is the login page shown and yet not directing to the appropriate page? Here are exert of main activity:

protected override void OnCreate(Bundle savedInstanceState)
        {
            Distribute.SetEnabledForDebuggableBuild(true);
            Distribute.ReleaseAvailable = OnReleaseAvailable;
            AppCenter.Start("android=00001111-2222-3333-4444-555566667777",
                   typeof(Analytics), typeof(Crashes), typeof(Distribute));
            Distribute.CheckForUpdate();
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;
            CrossCurrentActivity.Current.Init(this, savedInstanceState);
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }

protected override void OnResume()
        {
            base.OnResume();
            InactivityCheck.startTimer(this);
        }

Upon logging, after checking that the login is correct, they are sent directly to a single page. There is no logic to chosing it that could interfere during the login.

I'm not the one that created the program originally and I'm not an expert in Xamarin forms, but beyond this part on the activity mostly with the saved instance, I could reliably follow and check that it wasn't an issue. Does anyone know what could be causing said issue?

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source