Device (device) hardware status, System State, network status
Introduced
Unique device for Windows Phone 7.5 (SDK 7.1)
Hardware status
System State
Network status
Example
1. Demonstrates how to obtain the related state of the hardware
HardwareStatus.xaml.cs
* * Demonstrates how to obtain hardware information for the device * * using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Net;
Using System.Windows;
Using System.Windows.Controls;
Using System.Windows.Documents;
Using System.Windows.Input;
Using System.Windows.Media;
Using System.Windows.Media.Animation;
Using System.Windows.Shapes;
Using Microsoft.Phone.Controls;
Using System.Windows.Navigation;
Using Microsoft.Phone.Info; namespace Demo.Device.Status {public partial class Hardwarestatus:phoneapplicationpage {public Har
Dwarestatus () {InitializeComponent ();
} protected override void Onnavigatedto (NavigationEventArgs e) {lblmsg.text = ""; * * Devicestatus-for obtaining relevant equipment information * * Lblmsg.text + + equipment Manufacturer: + Dev
Icestatus.devicemanufacturer;
Lblmsg.text + = Environment.NewLine; Lblmsg.text + = "Device Name:" + DeviCestatus.devicename;
Lblmsg.text + = Environment.NewLine; Lblmsg.text + = "Total Physical Memory:" + devicestatus.devicetotalmemory;
Unit: Byte Lblmsg.text + = Environment.NewLine; Lblmsg.text + = "System is allocated to the maximum available memory for the current application:" + devicestatus.applicationmemoryusagelimit;
Unit: Byte Lblmsg.text + = Environment.NewLine; Lblmsg.text + = "Current application uses memory Current value: + Devicestatus.applicationcurrentmemoryusage;"
Unit: Byte Lblmsg.text + = Environment.NewLine; Lblmsg.text + = "Current application uses memory Peak value:" + devicestatus.applicationpeakmemoryusage;
Unit: Byte Lblmsg.text + = Environment.NewLine;
Lblmsg.text + + "Hardware version:" + devicestatus.devicehardwareversion;
Lblmsg.text + = Environment.NewLine;
Lblmsg.text + + "firmware version:" + devicestatus.devicefirmwareversion;
Lblmsg.text + = Environment.NewLine;
Lblmsg.text + = "Does the device contain a physical keyboard:" + devicestatus.iskeyboardpresent; Lblmsg.text + = Environment.NewLine;
Lblmsg.text + = "Physical keyboard is being used:" + devicestatus.iskeyboarddeployed;
Lblmsg.text + = Environment.NewLine; * * Microsoft.Phone.Info.PowerSource Enumeration-power supply Mode * Battery-Battery * externa
L-External power supply/lblmsg.text + + = "Power supply mode:" + Devicestatus.powersource;
Lblmsg.text + = Environment.NewLine;
Lblmsg.text + = "Whether to support the smooth streaming processing of multiresolution encoded video:" + mediacapabilities.ismultiresolutionvideosupported;
Lblmsg.text + = Environment.NewLine;
Lblmsg.text + + "Equipment identification:" + Getdeviceuniqueid (); The event that is triggered when the use state (use or shutdown) of the physical keyboard changes, devicestatus.keyboarddeployedchanged + = new EventHandler (devicestatus_keyboar
ddeployedchanged); The event that is triggered when a device's power supply (battery or external power supply) changes devicestatus.powersourcechanged + = new EventHandler (DEVICESTATUS_POWERSOURCEC
hanged); } void Devicestatus_powersourcechanged (object sender, EventArgs e) {MessageBox.Show (
"Power supply Mode:" + Devicestatus.powersource); } void Devicestatus_keyboarddeployedchanged (object sender, EventArgs e) {messagebox.sh
ow ("Physical keyboard is being used:" + devicestatus.iskeyboarddeployed); ///<summary>///Gets the unique ID of the device///</summary> private string Getdeviceu
Niqueid () {string result = ' ";
Object uniqueId; * * Deviceextendedproperties.trygetvalue ()-To obtain a unique ID for the device/if (Deviceextendedpro Perties.
TryGetValue ("Deviceuniqueid", Out UniqueId)} {result = Bytetohexstr ((byte[)) uniqueId); If result!= null && result. Length = =) Result = result. Insert (8, "-"). Insert (17, "-"). Insert (26, "-").
Insert (35, "-"); return result; ///<summary>///Converts a byte array to a hexadecimal string///</summary> private string by
Tetohexstr (byte[] bytes) {String returnstr = ""; if (bytes!= null) {for (int i = 0; i < bytes.) Length; i++) {returnstr + = Bytes[i].
ToString ("X2");
} return RETURNSTR; }
}
}