在Xbox 1 UWP中查找当前活动用户 [英] Find currently active user in xbox one UWP

查看:123
本文介绍了在Xbox 1 UWP中查找当前活动用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码,我可以获取所有已登录用户的列表.有没有办法知道当前的活动用户是谁?

Using the below code I am able to get the list of all signed in users. Is there a way to know which is the current active user?

 IReadOnlyList<User> users = await Windows.System.User.FindAllAsync();

推荐答案

我最近亲自遇到了这个问题,并发布了有关此问题的信息

I recently ran into this problem myself, and posted about it here. Someone responded there, and gave me some pretty big hints, which in turn helped me to get this solved.

这里又快又脏(我的UWP是基于HTML/JavaScript的BTW):

Here is the quick and dirty (my UWP is HTML/JavaScript based BTW):

首先,如果您要在项目中包含 WinJS库还没有.然后,在启动应用程序时,您只需要一点代码即可捕获活动用户...

First, include the WinJS library in your project, if you don't already have it. Then, you just need a little bit of code to grab the active user, when the application is launched...

WinJS.Application.addEventListener('activated', function (args) {
    args.detail.user // <-- the active user!!
});

为使此功能有用,您需要向VS解决方案授予"userAccountInformation"功能.为此:

In order for this to be of any use, you need to grant your VS Solution, the "userAccountInformation" capability. To do that:

  1. 打开您的Visual Studio解决方案(我正在使用VS 2015).
  2. 双击您的appxmanifest文件.
  3. 点击功能"标签.
  4. 选中标题为用户帐户信息"的选项.

这篇关于在Xbox 1 UWP中查找当前活动用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆