What is the "Session" in SystemTriggerType?
-
martedì 1 novembre 2011 03:08In API Windows.ApplicationModel.Background, there are three SystemTriggerType as SessionStart, SessionConnected and SessionDisconnected. But, I don't understand and how to use?
Tutte le risposte
-
mercoledì 2 novembre 2011 13:09Moderatore
Hi Jones,
The term session refers to a Windows user session. These events are available only to lockscreen apps. An app can figure out its lockscreen state using the lockscreen events.
-Jeff
Jeff Sanders (MSFT)- Proposto come risposta Jeff SandersMicrosoft Employee, Moderator mercoledì 2 novembre 2011 13:09
- Contrassegnato come risposta Bob_BaoMVP, Moderator mercoledì 7 dicembre 2011 09:24
-
giovedì 3 novembre 2011 01:49
Thanks for your prompt reply. but still fail to trigger background task after add my app into lockscreen, is there any sample code for reference?
-
giovedì 3 novembre 2011 20:29Moderatore
Hi Jones,
I took the BackgroundTaskSample and modified it to capture the Windows.ApplicationModel.Background.SystemTriggerType.sessionStart event
First in program.js, I modified the function registerSampleJavaScriptBackgroundTask and had it set the SystemTrigger to Windows.ApplicationModel.Background.SystemTriggerType.sessionStart.
Then I modified the UI to dump some localSettings so I could see if the background task was being invoked. I added this to initialize: var localSettings = Windows.Storage.ApplicationData.current.localSettings;
sdkSample.displayError(localSettings.values["loginfo"]);Then I added this to backgroundtask.js to set a value so that I could tell if the systemTrigger was being called:
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
localSettings.values["loginfo"] = "Background " + backgroundTask.taskInstance.task.name + " Starting...";
Finally I add the icons to the manifest for Wide Logo, Badge Logo, Gave a short name and ensured Show Name was enabled, said that it was Toast Capable and Lock Screen Notifications I set to Badge and Title Text.Then I started the app in the debugger and registered the JavaScript Sample background task. (note the UI should show a blue 'undefined' text. Then I quit the app and added it as the lockscreen app. I logged off, logged back on and waited so that the background task to execute. Then I start the app again and the 'Background' text appeared in the UI indicating that the startingEvent did indeed kick off when I logged on.
-Jeff
Jeff Sanders (MSFT)- Contrassegnato come risposta Bob_BaoMVP, Moderator mercoledì 7 dicembre 2011 09:24
-
venerdì 4 novembre 2011 06:42Work it!! Thanks very much for your help!

