问题
In windows 8 metro style app, how to update live tile while app is not running ?
And the live tile start to run when OS system begin to start.
http://blogs.msdn.com/b/windowsappdev/archive/2012/04/16/creating-a-great-tile-experience-part-1.aspx
"3.Use polling notifications from the cloud to update the tile while the app is not running"
But I cannot find any example code.
I also try MSDN's PushNotificationSample, But I don't know how to set the "Server URI"?
Does anyone have similar experiences?
回答1:
Okay, let's get you answered! Here is every single way and resources for each way to get you started. Your scenario isn't clear to me, so I will try to be generic.
There are four ways to update a live tile in Windows 8! And this is true for the primary app tile and the subsequent secondary tiles created by the app, too.
1> The first is that the app, while running, can update the tile
- http://thesociablegeek.com/windows-8/livetiles/working-with-live-tiles-locally/
But, you were asking how to update when it is not running:
2> A user can deploy a background task with their Windows 8 app. This background task executes periodically and can update the tile of the app during its execution. The minimum frequency of background tasks is 15 minutes. Windows 8 allocates 1 CPU second every two hours to a task. Your task can execute as often as you want until you exhaust its allocation.
- http://thesociablegeek.com/windows-8/livetiles/modifying-live-tiles-in-a-background-process/
3> An app can open a WNS (Windows Notification Services) channel while it is running. When it is not running, a web service can push tile updates across WNS.
- http://msdn.microsoft.com/en-us/library/windows/apps/hh465460.aspx
- http://visualstudiomagazine.com/articles/2012/03/25/using-push-notifications-in-windows-8.aspx
- http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh868253(v=win.10).aspx
4> A tile can be configured to pull from a URL. The XML from that URL is periodically evaluated for deltas and the tile is refreshed when detected. Tiles expire by default after three days.
- http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.startperiodicupdate.aspx
- http://msdn.microsoft.com/en-us/library/windows/apps/hh761476.aspx
Point of clarification: you can't cause something like a tile update when the OS is booted. For one, in Windows 8 the idea of rebooting (or at least shutting down) is practically deprecated. But your Store app can only execute in the ways above - and can't do something like the StartUp folder (in the past) or RegEdit/Run (in the past) just the stuff above. But maintenance or timer triggers get you pretty close.
And, that's the answer. Best of luck, dude!
回答2:
Try background tasks @ http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9
来源:https://stackoverflow.com/questions/11607778/in-windows-8-metro-style-app-how-to-update-live-tile-while-app-is-not-running