Introduction



Home Screen :

Name of Experiment : Device Info (includes information related to Device such as Hardware version, Firmware version, Device Manufacturer, Device name, Total Memory, Application current memory usage, Application peak memory usage etc. )

Exp No : MC2

Background : Student should have a basic knowledge of C#.

Summary : User sometimes required to know, certain system defined properties that are abstracted from the end user. These properties must be known to user during updating of OS or updating the firmware.

Learning Objective : Here, Student should learn the procedure to get all necessary details about the device. After, doing this experiment user himself know the running firmware version, hardware version, Device name, Total Memory etc.

Target

Target Platform : This experiment is tested on Windows Phone Emulator and Nokia Lumia (800).

Procedure

SourceCode

Source Code : Comments :
MainPage.xaml
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock x:Name="ExperimentTitle" Text="Exp.No.MC2" TextAlignment="Right" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="ApplicationTitle" Text="Mobile Computing" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Device info" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Margin="12,6,6,70" Orientation="Vertical" >
<TextBlock x:Name="tbkeyDeployed" Text="" Height="43" />
<TextBlock x:Name="tbkeyPresent" Text="" Height="43"/>
<TextBlock x:Name="tbPowerS" Text="" Height="43"/>
<TextBlock x:Name="tbApplicationCurrentMem" Text="" Height="43"/>
<TextBlock x:Name="tbApplicationPeakMem" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceMem" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceName" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceManu" Text="" Height="43"/>
<TextBlock x:Name="tbFWareVer" Text="" Height="43"/>
<TextBlock x:Name="tbHwVer" Text="" Height="43"/>
<TextBlock x:Name="tbMultiVideo" Text= “ ” Height="43"/>
</StackPanel>
</Grid>
</Grid>


 Exp No. MC2

 Mobile Computing
 Device Info2
MainPage.xaml.cs
using System;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Info;


namespace DeviceInfo
{
public partial class MainPage : PhoneApplicationPage

{
string s1, s2, s3, s4, s5,s6;
bool b1, b2,b3;
long l1, l2, l3;
// Constructor
public MainPage()
{
InitializeComponent();
Loaded+=new RoutedEventHandler(MainPage_Loaded);
}
//Initialising the UI
public void MainPage_Loaded(object sender,RoutedEventArgs e) {
b1=IsKeyboardDeployed;
tbkeyDeployed.Text=String.Format("IskeyboardDeployed: {0}\r\n",b1);
b2=IsKeyboardPresent;
tbkeyPresent.Text=String.Format("IskeyboardPresent:{0}\r\n",b2);
s1=PowerSource;
tbPowerS.Text=String.Format("PowerSource: {0}\r\n",s1);
l1=ApplicationCurrentMemoryUsage;
tbApplicationCurrentMem.Text=
String.Format("ApplicationCurrentMemoryUsage:{0}\r\n",l1);
l2=ApplicationPeakMemoryUsage;
tbApplicationPeakMem.Text=
String.Format("ApplicationPeakMemoryUsage:{0}\r\n",l2);
l3=DeviceTotalMemory;
tbDeviceMem.Text=
String.Format("DeviceTotalMemory:{0}\r\n",l3);
s2=DeviceName;
tbDeviceName.Text=String.Format("DeviceName:{0}\r\n",s2);
s3=DeviceManufacturer;
tbDeviceManu.Text=String.Format("DeviceManufacturer:{0}\r\n",s3);
s4=DeviceFirmwareVersion;
tbFWareVer.Text=String.Format("DeviceFirmwareVersion:{0}\r\n",s4);
s5=DeviceHardwareVersion;
tbHwVer.Text=String.Format("DeviceHardwareVersion:{0}\r\n",s5);
b3 = IsMultiResolutionVideoSupported;
tbMultiVideo.Text = String.Format("MultiResolutionVideoSupported:{0}\r\n",b3);

}
// Overriding the Methods, defined in DeviceStatus and //MediaCapabilities class
public bool IsKeyboardDeployed { get {
return DeviceStatus.IsKeyboardDeployed; } }
public bool IsKeyboardPresent { get {
return DeviceStatus.IsKeyboardPresent; } }
public string PowerSource { get {
return DeviceStatus.PowerSource.ToString(); } }
public long ApplicationCurrentMemoryUsage { get {
return DeviceStatus.ApplicationCurrentMemoryUsage; } }
public long ApplicationPeakMemoryUsage { get {
return DeviceStatus.ApplicationPeakMemoryUsage; } }
public long DeviceTotalMemory { get {
return DeviceStatus.DeviceTotalMemory; } }
public string DeviceName { get {
return DeviceStatus.DeviceName; } }
public string DeviceFirmwareVersion { get {
return DeviceStatus.DeviceFirmwareVersion; } }
public string DeviceHardwareVersion { get {
return DeviceStatus.DeviceHardwareVersion; } }
public string DeviceManufacturer { get {
return DeviceStatus.DeviceManufacturer; } }
public bool IsMultiResolutionVideoSupported { get {
return MediaCapabilities.IsMultiResolutionVideoSupported; } }
}
}


 Add Reference for Microsoft.Phone.Info

Snapshots





Observation

Observation : It is observed that after running this DeviceInfo experiment, end user now get to know some information related to device which are abstracted from him.

Video Link

For Windows Phone

Download

Right Click Here And Select Save Target For Entire Download :

Device Info Experiment