随着 2015 年 11 月 18 日的新更新。Windows 应用程序认证工具包正在检查预发布测试,我尝试使用此示例
https://msdn.microsoft.com/en-us/library/windows/apps/mt593297.aspx
但是,力求为 WinJS 找到一个示例。如何在 WinJS 应用程序中执行此操作?
随着 2015 年 11 月 18 日的新更新。Windows 应用程序认证工具包正在检查预发布测试,我尝试使用此示例
https://msdn.microsoft.com/en-us/library/windows/apps/mt593297.aspx
但是,力求为 WinJS 找到一个示例。如何在 WinJS 应用程序中执行此操作?
您应该检查功能args.detail.prelaunchActivated
。app.onactivated
以下代码是从 Visual Studio 2015 Update 1 构建的模板更新而来,并已参考 C++/C# 的模板
默认.js
// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState === activation.ApplicationExecutionState.terminated) {
// TODO: This application was suspended and then terminated.
// To create a smooth user experience, restore application state here so that it looks like the app never stopped running.
}
if (!args.detail.prelaunchActivated) {
// TODO: This is not a prelaunch activation. Perform operations which
// assume that the user explicitly launched the app such as updating
// the online presence of the user on a social network, updating a
// what's new feed, etc.
}
args.setPromise(WinJS.UI.processAll());
}
};
app.oncheckpoint = function (args) {
// TODO: This application is about to be suspended. Save any state that needs to persist across suspensions here.
// You might use the WinJS.Application.sessionState object, which is automatically saved and restored across suspension.
// If you need to complete an asynchronous operation before your application is suspended, call args.setPromise().
};
app.start();
})();