2013-07-02 105 views
7

我想以編程知道,因爲它是在有關網頁設置顯示設備型號about page信息(型號)

我目前使用

Microsoft.Phone.Info.DeviceStatus.DeviceName 

,但它並不能幫助並給出了一些其他的典型值。 請幫助我如何獲得手機型號/名稱如上。

+0

在其電話你測試你的代碼,你從調用DeviceStatus.DeviceName或DeviceStatus.DeviceManufacturer獲得哪個值? – Haspemulator

+0

我正在測試Lumia 520和DeviceStatus.DeviceName給出這樣的值RM-914_im_india_389和DeviceStatus.DeviceManufacturer給諾基亞的價值,但我解決了這個使用[PhoneNameResolver](https://github.com/ailon/PhoneNameResolver)建議[Olivier Payen](http://stackoverflow.com/questions/17425016/information-about-windows-phone-model-number?answertab=votes#tab-top) – Jatin

回答

7

你應該使用PhoneNameResolver,一個簡單的類,解決了模糊的設備名稱,如

RM-885_apac_prc_250

成友好的商業名稱,如

諾基亞Lumia 720

下面是一個示例代碼:

var phone = PhoneNameResolver.Resolve(
    DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceName); 
SomeTextBox.Text = phone.FullCanonicalName; 

在這篇博客文章更多信息:http://devblog.ailon.org/devblog/post/2013/01/21/Introducing-PhoneNameResolver%E2%80%93a-lib-to-decipher-Windows-Phone-models.aspx

+0

謝謝你,那就是我正在尋找的東西 – Jatin

0

您可以使用PhoneInfo的擴展屬性檢索DeviceName,因此here's the link。經測試和今天工作到今天;)

享受。

+2

這似乎產生相同的變體名稱(RM-914_im_india_389 )與使用未棄用的DeviceStatus.DeviceName一樣。 – GrahamW

1

你可以使用這樣的功能: -

 public static string getDeviceInfo(bool asList = false) 
    { 
     string r = ""; 

     Geolocator locationservice = new Geolocator(); 

     if (DeviceNetworkInformation.CellularMobileOperator != "") r += "CellularMobileOperator: " + DeviceNetworkInformation.CellularMobileOperator + Environment.NewLine; 
     r += "CellularDataEnabled: " + DeviceNetworkInformation.IsCellularDataEnabled + Environment.NewLine; 
     r += "WiFiEnabled: " + DeviceNetworkInformation.IsWiFiEnabled + Environment.NewLine; 
     r += "IsNetworkAvailable: " + DeviceNetworkInformation.IsNetworkAvailable + Environment.NewLine; 
     r += "Hardware Identifier: " + Convert.ToBase64String((byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId")) + Environment.NewLine; 
     r += "Location Services Permission: " + locationservice.LocationStatus + Environment.NewLine; 

     r += "Language: " + CultureInfo.CurrentCulture.EnglishName + Environment.NewLine; 
     r += "Locale: " + CultureInfo.CurrentCulture.Name + Environment.NewLine; 
     //r += "Background Service Enabled: " + ScheduledActionService.Find("PeriodicAgent").IsEnabled + Environment.NewLine; 
     r += "Runtime Version: " + Environment.Version + Environment.NewLine; 
     r += "Maximum Memory: " + (DeviceStatus.DeviceTotalMemory/(1024 * 1024)) + "M" + Environment.NewLine; 
     r += "Maximum Memory Available: " + (DeviceStatus.ApplicationMemoryUsageLimit/(1024 * 1024)) + "M" + Environment.NewLine; 
     r += "Peak Memory Use: " + (DeviceStatus.ApplicationPeakMemoryUsage/(1024 * 1024)) + "M" + Environment.NewLine; 
     r += "Charger: " + DeviceStatus.PowerSource + Environment.NewLine; 
     r += "DeviceFirmwareVersion: " + DeviceStatus.DeviceFirmwareVersion + Environment.NewLine; 
     r += "DeviceManufacturer: " + DeviceStatus.DeviceManufacturer + Environment.NewLine; 
     r += "OS Version: " + Environment.OSVersion + Environment.NewLine; 
     r += "User ID: " + settings[KeyString.USER_ID] + Environment.NewLine; 
     var phone = PhoneNameResolver.Resolve(DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceName); 
     r += "Phone model(userfriendly form):" +phone.FullCanonicalName ; 
     return r; 
    }