我试图在这个 WP7 应用程序中找到解决方案崩溃:
- 创建新的 WP7 应用程序。
允许应用在锁定屏幕中运行:
// in App() PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
- 在 MainPage 中放置按钮
添加运行 CameraCaptureTask 的按钮代码:
var cameraCapture = new CameraCaptureTask(); cameraCapture.Completed += cameraCapture_Completed; cameraCaptureTask.Show();
- 带硬件按钮的锁屏。
- 解锁屏幕 - 崩溃 :-(
例外:
System.Runtime.InteropServices.COMException - "0x8000ffff"
堆栈跟踪:
at Microsoft.Phone.Execution.NativeEmInterop.NotifyFullObscurityChanged(Boolean isObscured)
at Microsoft.Phone.Shell.PhoneApplicationService.OnFullObscurityChanged(Object sender, LockStateChangeEventArgs e)
at Microsoft.Phone.Shell.Interop.ShellPageManager.ShellPageCallback_OnLockStateChange(Object source, LockStateChangeEventArgs e)
at Microsoft.Phone.Shell.Interop.ShellPageCallback.FireOnLockStateChange(Boolean fLocked)
它在真实硬件(Samsung Omnia W)中崩溃 - 没有模拟器。我确实使用 EmailComposeTask/CameraCaptureTask/PhotoChooserTask 对此进行了测试 - 总是崩溃。
编辑:
破解应用程序的步骤:
- 项目模板:Windows Phone 应用程序
- 目标 Windows Phone 操作系统版本:Windows Phone OS 7.1
App.xaml.cs - 只添加了一行,然后在 App 构造函数的末尾:
[...]
public App()
{
UnhandledException += Application_UnhandledException;
InitializeComponent();
InitializePhoneApplication();
if (System.Diagnostics.Debugger.IsAttached)
{
Application.Current.Host.Settings.EnableFrameRateCounter = true;
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
}
[...]
MainPage.xaml,添加按钮:
<Button Content="Button" HorizontalAlignment="Left" Margin="361,262,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
MainPage.xaml.cs - 添加的方法:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
PhotoChooserTask objPhotoChooser = new PhotoChooserTask();
objPhotoChooser.Completed += objPhotoChooser_Completed;
objPhotoChooser.Show();
}
private void objPhotoChooser_Completed(object sender, PhotoResult e)
{
}
连接手机,编译并部署程序到手机,断开手机(PhotoChooserTask不适用于Zune)。在您的设备中运行程序,单击“按钮”,使用硬件按钮锁定屏幕,然后将其解锁 - 崩溃并关闭程序。您可以使用 WPConnect 而不是 Zune 来调试它。