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


猜你喜欢
- 利用Unity制作特写镜头的示例代码 2023-05-30
- Graphics.DrawImage绘制的图像变大的原因分析及解决 2023-05-06
- C#综合揭秘——细说多线程(上)C#综合揭秘——细说进程、应用程序域与上下文 2023-11-14
- C#/ .Net启动进程,退出代码为-2146234327 2023-09-19
- 详解C#扩展方法原理及其使用 2023-03-03
- C#基于WinForm实现串口通讯 2023-05-22
- c# – Windows Phone 8 – 将列表保存到IsolatedStorage 2023-09-18
- 基于数据类型转换(装箱与拆箱)与常量详解 2022-11-24
- C#泛型详解 2023-05-25
- C#-在Windows 8.1运行时应用程序中动态加载Xaml 2023-11-16