[UWP]如何检测我的Windows 10应用是否在模拟器或真实移动设备上运行?

问题描述:

如何知道我的应用目前是否在Windows Phone模拟器或真实设备中运行?

How can I know if my app is currently running in a Windows Phone emulator or real device?

好像http://*.com/questions/24811760/determine- if-windows-phone-8-1-app-is-the-the-emulator
不再适用。

注意:

我最初在这里问过:  https://social.msdn.microsoft.com/Forums/en-US/ce27a2be-bc40- 4dbd-a1d9-a7bda3c6497b / uwpat-runtime-how-to-detect-platform-store-or-phone-and-emulator-in-a-windows-10-app?forum = wpdevelop但是因为只有问题的第一部分
得到回答,我创建了一个单独的问题并更改了标题以提高可见度

I originally asked it here: https://social.msdn.microsoft.com/Forums/en-US/ce27a2be-bc40-4dbd-a1d9-a7bda3c6497b/uwpat-runtime-how-to-detect-platform-store-or-phone-and-emulator-in-a-windows-10-app?forum=wpdevelop but since only first part of the question was answered, I created a separate question and changed title for better visibility

你好Virgile,

Hi Virgile,

首先想到的是 #if  DEBUG ,而且模拟器不是模拟器或者,模拟器可以模拟真实设备。

The first thing come to my mind is #if DEBUG, furthermore emulator is not simulator, emulator is the one that can emulate the real device.

Windows 手机模拟器是一个模拟Windows手机设备的桌面应用程序。它提供了一个虚拟化环境,您可以在其中调试和测试Windows 手机应用程序,而无需物理设备。它还为您的应用程序原型提供了隔离的环境

但我想知道你为什么要检测应用程序是否在模拟器或真实设备中运行,如果你能为你的场景解释更多,也许我们可以给你一些建议。

But I would like to know why you want to detect if the app runs in emulator or real device, if you can explain more for your scenario, perhaps we can give you some suggestions.

- 詹姆斯