我正在尝试在此WP7应用中找到解决方案崩溃:
允许应用在锁定屏幕中运行:
// in App()
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
添加按钮代码,运行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)
它在真实硬件(三星Omnia W)中崩溃 - 没有模拟器。 我用EmailComposeTask / CameraCaptureTask / PhotoChooserTask对此进行了测试 - 总是崩溃。
修改
抓住应用程序的步骤:
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来调试它。
答案 0 :(得分:0)
我在WP8设备(Lumia 820开发版)上测试了这个并且工作正常。我能看到的唯一问题是当你解锁设备时,你没有回到启动器屏幕而是回到应用程序屏幕。我假设,该问题与WP7和WP8上Launchers的低级实现中的不同评估有关。