Brian Vallelunga
Brian Vallelunga

Reputation: 10181

Determine if Windows Phone 8.1 app is running in the emulator?

In an 8.1 Universal app, is there an equivalent to:

if (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator)
{
  // Emulator-specific code
}

I've looked and can't find a similar API.

Upvotes: 5

Views: 1066

Answers (2)

mihania
mihania

Reputation: 13

You could try something like this:

if (Windows.ApplicationModel.Package.Current.IsDevelopmentMode)
{
  // Emulator-specific code
}

https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.isdevelopmentmode.aspx

Upvotes: 0

Igor Ralic
Igor Ralic

Reputation: 15006

You could try something like this:

Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();

deviceInfo should give you info about SystemManufacturer ("Microsoft") & SystemProductName ("Virtual").

EDIT: I wrote a blog post about this problem.

Upvotes: 3

Related Questions