0

In my UWP and Windows Phone 8.1 projects only OnStart is called. When I exit the app via the back button or home button, OnSleep is not called. If I open the app OnResume is not called.

It looks like the app never goes in the Deactivated state.

I tried it with Android and it is working fine. Why are these methods not called in both Windows projects?

stefana
  • 2,606
  • 3
  • 29
  • 47
  • Which version of `Xamarin.Forms` are you using? – SushiHangover Apr 18 '16 at 08:16
  • I am using 2.1.0.6529 which is the latest stable release. – stefana Apr 18 '16 at 08:21
  • I know there were issues related to this exact problem under 2.0.x, you might want to try the prerelease version, 2.2.0.5-pre2, in a sample project to see if these events are being called. In regarding to the older version, see https://forums.xamarin.com/discussion/52524/windows-8-1-windows-phone-8-1-windows-10-related-issues – SushiHangover Apr 18 '16 at 08:30
  • I have tried the latest prelease, but no luck. Might [this](http://stackoverflow.com/questions/24103101/suspending-event-not-raising-using-winrt) be related? – stefana Apr 18 '16 at 09:18
  • 1
    Have you tried setting the LifeCycle to suspend and then back to resume via the `LifeCycle Events` in VS? Does the `OnResume` event in Forms get called then? – SushiHangover Apr 18 '16 at 09:24
  • Yes, they do get called that way. – stefana Apr 18 '16 at 09:47
  • Great, than that bug was fixed... – SushiHangover Apr 18 '16 at 09:48

1 Answers1

0

This was a known bug in Xamarin.Forms 2.0: OnStart / OnResume are not called on WP8.1 which according to bugzilla was fixed in 2.1.0-pre1 version. If this is still not working for you, you should reopen the issue and attach your project which reproduces the issue.

As a workaround you can try using application lifecycle event in windows phone project: App lifecycle but this is obviously platform specific solution.

Giorgi
  • 30,270
  • 13
  • 89
  • 125