我的应用程序使用计时器来振动设备.现在,我想在接听电话时停止此计时器,否则设备也会在通话期间继续振动,并在通话结束时重新启动.我试图处理模糊和不模糊的事件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应用程序中的呼叫


基础教程推荐
猜你喜欢
- C# API中模型与它们的接口设计详解 2022-12-26
- c#计算某段代码的执行时间实例方法 2023-01-16
- C#委托用法详解 2023-05-22
- C#中public变量不能被unity面板识别的解决方案 2023-04-14
- c#-由进程“系统”引起的高CPU使用率 2023-11-27
- c++换行符知识点总结 2023-02-08
- C#实现自定义线程池实例代码 2023-06-21
- unity置灰处理的实现 2023-04-22
- C#匿名函数和匿名方法的使用 2023-07-18
- C# 实现WebSocket服务端教程 2023-03-14