locked
Request Lock Screen Access throws an exception in simulator

    Question

  • I am getting this error:

    WinRT information: You can’t change background task and lock screen privileges while running this app in the simulator.

    When I try to request access to lock screen like this...  was working in previous version of VS/Win8 - broken in RC

        function requestLockScreenAccess() {
            var Background = Windows.ApplicationModel.Background;
            //
            // An app can call the add or query API as many times as it wants; however, it will only present the dialog box to the user one time.
            //
            Background.BackgroundExecutionManager.requestAccessAsync().then(function (result) {
                switch (result) {
                    case Background.BackgroundAccessStatus.denied:
                        console.log("This app is not on the lock screen.");
                        break;
    
                    case Background.BackgroundAccessStatus.allowedWithRealTimeConnectivity:
                        console.log("This app is on the lock screen and has access to Real Time Connectivity.");
                        break;
    
                    case Background.BackgroundAccessStatus.allowedWithoutRealTimeConnectivity:
                        console.log("This app is on the lock screen, but does not have access to Real Time Connectivity.");
                        break;
    
                    case Background.BackgroundAccessStatus.unspecified:
                        console.log("The user has not yet taken any action. This is the default setting and the app is not on the lock screen.");
                        break;
                }
            }, function (e) {
                console.log(e);
            });
        }


    www.emadibrahim.com

    Friday, June 01, 2012 10:08 AM

Answers

  • Right... the error says it all: "You can’t change background task and lock screen privileges while running this app in the simulator."

    Why do you need to do this?

    -Jeff


    Jeff Sanders (MSFT)

    Tuesday, June 05, 2012 6:14 PM
    Moderator

All replies

  • Right... the error says it all: "You can’t change background task and lock screen privileges while running this app in the simulator."

    Why do you need to do this?

    -Jeff


    Jeff Sanders (MSFT)

    Tuesday, June 05, 2012 6:14 PM
    Moderator
  • For testing purposes... but no big deal, i will use the "real" machine for testing background tasks.

    www.emadibrahim.com

    Wednesday, June 06, 2012 2:36 PM