我的应用程序使用计时器来振动设备.现在,我想在接听电话时停止此计时器,否则设备也会在通话期间继续振动,并在通话结束时重新启动.我试图处理模糊和不模糊的事件PhoneApplicationFrame rootFrame = App.Current.RootV...

我的应用程序使用计时器来振动设备.现在,我想在接听电话时停止此计时器,否则设备也会在通话期间继续振动,并在通话结束时重新启动.我试图处理模糊和不模糊的事件
PhoneApplicationFrame rootFrame = App.Current.RootVisual as PhoneApplicationFrame;
if (rootFrame != null)
{
rootFrame.Obscured += new EventHandler<ObscuredEventArgs>(rootFrame_Obscured);
rootFrame.Unobscured += new EventHandler(rootFrame_Unobscured);
}
但这不起作用.收到呼叫时未发生这些事件.我该如何处理?
解决方法:
在App.xaml.cs中,有两种方法,如下所示.第一个在应用程序导航至时触发,第二个在您从应用程序导航时触发(例如,在接到电话时).
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
//start timer here
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
//stop timer here
}
织梦狗教程
本文标题为:首页> C#>如何处理Windows Phone 8应用程序中的呼叫


基础教程推荐
猜你喜欢
- RabbitMQ的配置与安装教程全纪录 2022-12-26
- C# Windows Form编程 2023-11-10
- C#获取所有进程的方法 2023-01-06
- C#多线程系列之任务基础(一) 2023-05-21
- 将剪贴板中的文本发送到应用程序,如记事本(C#或Powershell) 2023-09-19
- 快速学习c# 枚举 2023-02-25
- Winform自定义控件在界面拖动、滚动鼠标时闪烁的解决方法 2023-05-11
- c# 如何对网络信息进行相关设置(ip,dns,网关等) 2023-04-09
- WPF自定义路由事件的实例教程 2023-04-27
- C#多线程系列之线程池 2023-05-21