WinStore.vn - Training Windows 8 - How and When Windows Store Apps Run

723 views

Published on

http://winstore.vn

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
723
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

WinStore.vn - Training Windows 8 - How and When Windows Store Apps Run

  1. 1. FOR WINDOWS 8 CAMP ATTENDEE USE ONLYNOT FOR REDISTRIBUTIONhttp://aks.ms/windows8campinabox http://dev.windows.com http://devcamps.ms/windows win8tkfb@microsoft.com
  2. 2. demo
  3. 3. Apps do not get notified when they are getting terminated
  4. 4. //Register for the Suspending event and call suspendingHandler when receivedWindows.UI.WebUI.WebUIApplication.addEventListener("suspending", suspendingHandler);//Handle the suspending event and save the current user session using WinJS sessionStatefunction suspendingHandler(eventArgs) {//We are getting suspended}//Register for the Resuming event and call resumingHandler when receivedWindows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler);function resumingHandler( ) {//We are getting resumed, in general do nothing}
  5. 5. demo
  6. 6. Scenario You should….
  7. 7. demo
  8. 8. UserLaunches App Splash screen
  9. 9. Windows.UI.WebUI.WebUIApplication.addEventListener("activated", activatedHandler);function activatedHandler(eventArgs) { /* aK.shareTarget || aK.cameraSettings || aK.contactPicker || aK.device || aK.file || aK.fileOpenPicker || .. */ // previous state:}
  10. 10. demo
  11. 11. Trigger ConditionSystemEventTrigger InternetAvailable, ControlChannelReset # InternetNotAvailable, InternetAvailable SessionConnected, LockScreenApplicationAdded/Removed SessionDisconnected, NetworkStateChange UserNotPresent, OnlineIdConnectedStateChange UserPresent ServicingComplete SessionConnected/Disconnected # SmsReceived TimeZoneChange UserAway/UserPresent #ControlChannelTrigger # (**)TimeTrigger #PushNotificationTrigger # (**)MaintenanceTrigger # requires lock permission **can run in App (not BackgroundTaskHost.exe)
  12. 12. function RegisterSampleBackgroundTaskWithCondition(){ var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); builder.name = "BackgroundTestWorker“; builder.taskEntryPoint = "BackgroundTestWorker.js";// run a timetrigger for every 15 minutes var myTrigger = new Windows.ApplicationModel.Background.TimeTrigger(15, false); builder.setTrigger(myTrigger);// required condition: internetAvailable var condition = newWindows.ApplicationModel.Background.SystemCondition(Windows.ApplicationModel.Background.SystemConditionType.internetAvailable); builder.addCondition(condition);// register the task var task = builder.register(); task.addEventListener("progress", task_Progress); task.addEventListener("completed", task_Completed);}
  13. 13. <Extensions> <Extension Category="windows.backgroundTasks" StartPage="jsbackgroundtask.js"> <BackgroundTasks> <Task Type="systemEvent" /> </BackgroundTasks> </Extension></Extensions>
  14. 14. demo
  15. 15. CPU resource quota Refresh period Lock screen appNon-lock screen app

×