我的WP7(silverlight)应用程序一直被拒绝,因为它“在来电时不应继续振动”。但是,仅仅对Applicaton_Deactivated
事件做出反应不允许我解决问题,因为在来电时没有调用此方法......
有问题的振动是通过DispatcherTimer
完成的,vibrator = VibrateController.Default;
vibratorTimer = new DispatcherTimer();
vibratorTimer.Tick += new EventHandler(vibrateRepatedly);
vibratorTimer.Interval = new TimeSpan(0, 0, 0, 0, UIConstants.VIBRATION_INTERVAL);
vibrationSpan = new TimeSpan(0, 0, 0, 0, UIConstants.VIBRATION_DURATION);
在电话后面的后台继续运行。将执行移动到主线程并没有改变任何东西。
应用只是在电话后继续正常运行吗?还是有办法阻止振动?
振动器和计时器的初始化:
private void vibrateRepatedly(object sender, EventArgs e)
{
vibrator.Start(vibrationSpan);
}
勾选方法:
{{1}}
答案 0 :(得分:6)
来电期间,系统会调用Obscured event
,而不是Application_Deactivated event
。
您将在应用程序中收到一个隐藏的事件,但由于来电,收到的短信或提醒,您无法区分是否这样。
Here是您获得的Obscured事件的MSDN文档的链接。您还可以检测到相应的Unobscured event
。