1.Activated
2.Suspended
3.Resumed
4.Terminated
对应的 js代码:
(function () { "use strict"; WinJS.Binding.optimizeBindingReferences = true; var app = WinJS.Application; var activation = Windows.ApplicationModel.Activation; // 一下 1,2,3 是app 的事件触发顺序 //1 app.onloaded = function (args) { debugger; } //2 app.onactivated = function (args) { debugger; }; //3 app.onready = function (args) { debugger; } //suspended app.oncheckpoint = function (args) { debugger; } // settings app.onsettings = function (args) { debugger; } app.onunload = function (args) { debugger; } //error app.onerror = function (args) { debugger; } app.start(); })();
获取 Activation type 和 previous app state
Activation type:
previous app state:
(function () { "use strict"; WinJS.Binding.optimizeBindingReferences = true; var app = WinJS.Application; var activation = Windows.ApplicationModel.Activation; app.onactivated = function (args) { var previousState = args.detail.previousExecutionState; /* previousState have five kinds of state : 1.notRuning: the app is not running 2.running : the app is running 3.suspended: the app was suspended 4.terminated: the app was terminated after it was suspended 5.closeByUser: the app was closed by user (using Alt+F4, for example) */ }; app.start(); })();