OnNavigatedTo打开屏幕并且应用程序来生活时被调用? [英] Does OnNavigatedTo get called when you turn on the screen and the app comes to life?

查看:190
本文介绍了OnNavigatedTo打开屏幕并且应用程序来生活时被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个奇怪的情况,我想在我的Windows Phone 8.1应用程序中调试,我不知道OnNavigatedTo在哪个时刻被调用。



显然,当您正常浏览视图时,它会被调用(并且我已经检查了跟踪它)。



我的疑问是出现在其他方面我想检查我们称之为你唤醒你的应用程序并关闭屏幕。



我的问题是:当你打开屏幕,屏幕保护程序离开,是否被称为OnNavigatedTo函数?



根据我在其他地方阅读过的一些手册,应该。 >

根据我的Debug.Writeline跟踪,似乎没有。



我需要检查一些条件并执行一些代码在视图出现之前/何时出现,我无法正确执行。



PS:是否存在我应该用来处理这个视图是becom在您将屏幕转换为OnNavigatedTo之后,显示/聚焦?



提前感谢。

解决方案

在Windows Phone 8.1运行时(商店应用程序)中,OnNavigatedTo 仅在导航期间调用。在暂停后恢复不会调用 - 您可以在此处阅读参考资料在MSDN


在挂起事件之前,OnNavigatedFrom事件正在被调用,但是当你恢复时,OnNavigatedTo不是称为


在您锁定屏幕的情况下,应用程式已被暂停,在您继续 OnNavigatedTo 之后不叫如果您查找可能被调用的某些事件,请查看 Window.Activated Window.VisibilityChanged 事件。



另一种情况是当您调试应用程序时,您的应用程序将不会被暂停,您将需要通过生命周期事件选项卡进行测试。


I'm dealing with a strange situation I want to debug in my Windows Phone 8.1 app, and I'm not sure in which moments OnNavigatedTo is called.

Obviously, it gets called (and I've checked tracing it with the debugger) when you navigate to the view normally.

My doubt arises in other point I want to check, let's call it "You wake up your application and the screen was shut off".

My question is: When you turn on the screen, and you swype the screen protector away, is "OnNavigatedTo" function called or not?

According to some manuals I've read somewhere else, it should.

According to my Debug.Writeline traces, it seems it doesn't.

I need to check some condition and execute some code before/when the view appears, and I'm unable to do it properly.

PS: Does it exist some other alternative event I should use to deal with "This view is becoming visible/focused after you turn the screen on" situation instead of "OnNavigatedTo" ?

Thanks in advance.

解决方案

In Windows Phone 8.1 Runtime (Store apps) OnNavigatedTo is called only during navigation. It's not called after resuming from suspension - you can read a reference here at MSDN:

before Suspending event, the OnNavigatedFrom event is being called, but when you Resume, the OnNavigatedTo is not called

In your case when you lock the screen, the app is suspended, after you resume OnNavigatedTo is not called. If you look for some events which may be called - take a look at Window.Activated and Window.VisibilityChanged events.

The other case is that when you debug your app, your app won't be suspended, you will need to test it via Lifecycle events tab.

这篇关于OnNavigatedTo打开屏幕并且应用程序来生活时被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆