locked
when can I call BackgroundExecutionManager::GetAccessStatus() without getting an exception?

    Question

  • If I call:

    using namespace Windows::ApplicationModel::Background;
    
    BackgroundAccessStatus status= BackgroundExecutionManager::GetAccessStatus();
    

    I get a exception of type:   Platform::COMException ^e   and  e->HResult is E_FAIL (  HRESULT:0x80004005 )

    with additional information "Unspecified error :  WinRT information: The application is not lock screen capable."

    This seems rather confusing, as the point of calling GetAccessStatus was to find out which status I have from the choices of : "Denied, AllowedWithAlwaysOnRealTimeConnectivity, AllowedMayUseActiveRealTimeConnectivity, or Unspecified"

     The documentation at http://msdn.microsoft.com/en-us/library/windows/apps/hh700462.aspx does not mention:

    1) That this exception is possible.
    2) How to avoid it.

    On this machine, Control Panel reports Screen Saver is set to "None". 

    Do others have any success using this method?  Does anybody know why I get the E_FAIL exception?

    Or is by design that I should get the E_FAIL when the screen saver is disabled?

     

    Thursday, November 22, 2012 6:26 PM

Answers

  • Hi,

    Did you enable the Background tasks (extension) in Declarations.

    Double click Package.appxmanifest ->Declarations -> Select Background Tasks.

    There are only three task types can be used in lockscreen TimeTrigger, PushNotificationTrigger, ControlChannelTrigger

    The lockscreen based on background task, so we should enable it first.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Andrew7Webb Monday, November 26, 2012 12:28 PM
    Monday, November 26, 2012 8:49 AM

All replies

  • Maybe this page can help you http://stackoverflow.com/questions/12650697/request-lockscreen-access-throws-exception-hangs-or-throws-exception-in-mscorlib
    Friday, November 23, 2012 1:02 AM
  • Hi,

    Did you enable the Background tasks (extension) in Declarations.

    Double click Package.appxmanifest ->Declarations -> Select Background Tasks.

    There are only three task types can be used in lockscreen TimeTrigger, PushNotificationTrigger, ControlChannelTrigger

    The lockscreen based on background task, so we should enable it first.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Andrew7Webb Monday, November 26, 2012 12:28 PM
    Monday, November 26, 2012 8:49 AM
  • I was able to avoid the exception by configuring a background task in the manifest as seen below.  I had been mislead by the documentation at http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977055.aspx which asked for some XML to be placed in "extensions" which I did not see any way to do.

    Thanks ...

    I still think the API documentation should declare what exceptions may occur, explain why they happen, and how to fix them.  Grin.

    Monday, November 26, 2012 12:38 PM
  • Hello,

     

    Thanks for your feedback, I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, November 27, 2012 6:47 AM