-
-
Save polatengin/1729f964672cacc68d85b6e0f73f6563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows 10 UWP uygulamasının Phone, Tablet veya Desktop cihazda çalıştığını bulmak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum DeviceType | |
{ | |
Phone, | |
Tablet, | |
Desktop, | |
Xbox, | |
IoT, | |
Continuum | |
} | |
public static DeviceType Detect() | |
{ | |
if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") | |
{ | |
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) | |
{ | |
KeyboardCapabilities keyboard = new KeyboardCapabilities(); | |
if (keyboard.KeyboardPresent > 0) | |
{ | |
return DeviceType.Continuum; | |
} | |
else | |
{ | |
return DeviceType.Phone; | |
} | |
} | |
else | |
{ | |
return DeviceType.Tablet; | |
} | |
} | |
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop") | |
{ | |
KeyboardCapabilities keyboard = new KeyboardCapabilities(); | |
if (keyboard.KeyboardPresent > 0) | |
{ | |
return DeviceType.Desktop; | |
} | |
else | |
{ | |
return DeviceType.Tablet; | |
} | |
} | |
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox") | |
{ | |
return DeviceType.Xbox; | |
} | |
else if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT") | |
{ | |
return DeviceType.IoT; | |
} | |
/// Yukarıdakilerin hiçbiri değilse, Desktop olmalı | |
return DeviceType.Desktop; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment