Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the device platform on Windows 10

Since one release binary will run on pc, xbox and phones, I need a way to fetch the device type on runtime.

It is doable by checking with the ApiInformation for present types, methods etc., but I believe there should be a more reliable way.

like image 947
Darius V Avatar asked Mar 26 '15 07:03

Darius V


People also ask

How do I enable a device portal in Windows 10?

Enable Developer Mode and Device Portal on your device (Settings -> Privacy & security -> For developers). Connect your device and PC through a local network or with USB. Navigate to the Device Portal page in your browser. This table shows the ports and protocols used by each device family.

How do I get to the Device Manager in Windows 10?

In the search box on the taskbar, type Device Manager, thenselect from the menu.

What is connected devices platform Windows 10?

That is a necessary service in Windows, it allows Windows 10 connect to devices like Bluetooth, Printers & Scanners, music players, storage devices, mobile phones, cameras... etc.


1 Answers

Currently (with the preview tools released 23-Mar-2015) there isn't an easy way to do this, other than (as you mention) using the ApiInformation methods to detect implementations of things that only exist on the specific platform you're after.

It would be nice if there were some helpers to do this and if none are in the final tooling I'm sure some will be created by helpful people in the community.

However, there is a really good reason not to have this in that it encourages broad assumptions about the device.

If it was possible to say "Am I running on a phone?" then if you got the response 'Yes' then it would be easy to make assumptions about what was possible with that device but not all phones have the same capabilities.
It looks like there will be a "mobile" version of Windows 10 for both phones and small tablets. If you were able to say "am I the 'mobile' version?" then again that wouldn't potentially answer all your questions and you'd have to still check individual API availabilities as the capabilities of a cheap tablet and a high end phone could be vastly different. (The inclusion of physical buttons on the device and the ability to make phone calls are two obvious examples.) Extending this further there are plenty of scenarios where you'd treat different platforms the same as the functionality exists on all of them. In this scenario you're code would be better of saying "Is such and such API available?", rather than saying "Am I running on desktop, Xbox or SurfaceHub?".
The IOT platform will likely further complicate this due to the range of functionality and capabilities different IOT devices will have available.

There are very few scenarios where you want to know the platform you're running on and not whether a specific API is available. Hopefully, by only exposing API availability Microsoft are encouraging developers to think about checking for what they actually need, rather than relying on broad, potentially incomplete, classifications of devices.

Just as with web development where you don't know what platform or browser you are running on, you shouldn't detect the platform and make assumptions about what capabilities that device will therefore have, you should detect if the specific capability you require is supported/enabled on the device before using it or exposing associated UI in your app.

like image 159
Matt Lacey Avatar answered Oct 06 '22 22:10

Matt Lacey