我試圖找到解決崩潰在這個WP7應用程序:WP7 ApplicationIdleDetectionMode和EmailComposeTask/CameraCaptureTask/PhotoChooserTask
- 創建新的WP7應用程序。
允許應用程序在鎖定屏幕上運行:
// in App() PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
- 在地方的MainPage按鈕
添加按鈕的代碼,它運行CameraCaptureTask:
var cameraCapture = new CameraCaptureTask(); cameraCapture.Completed += cameraCapture_Completed; cameraCaptureTask.Show();
- 鎖屏,硬件按鈕。
- 解鎖屏幕 - CRASH :-(
例外:
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進行測試 - 總是崩潰。
編輯:
步驟crach應用:
- 項目模板:Windows Phone應用程序
- 目標的Windows Phone OS版本:Windows手機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來進行調試。
你可以發佈一個完整的,最小的repro,所以我們可以看到你是如何使用你發佈的代碼。 –