Array

Device Information

Must Read

Federal Grant Money For Debt Consolidation Can Come to Your Rescue

The federal government sets aside millions of dollars every year so as to be distributed in the form of...

The Tailspin Scenario

This chapter introduces a fictitious company named Tailspin. Tailspin’s flagship product is an online service named Surveys that enables...

Working with the Collections Module

Collections are another in a series of containers that you can use to store information in memory. For IronPython...
Admin
test

Windows Phone 7 includes the DeviceExtendedProperties class that you can use to obtain information about the physical device. The information you can retrieve includes the following:

  • The device manufacturer, the device name, and its unique device ID
  • The version of the phone hardware and the version of the firmware running on the phone
  • The total physical memory (RAM) installed in the device, the amount of memory currently in use, and the peak memory usage of the current application

However, you must be aware that the phone will alert the user when some device information is retrieved and the user can refuse to allow the application to access it. You should access device information only if it is essential to your application. Typically, you will use device information to generate statistics or usage data, and to monitor memory usage of your application. You can use this data to adjust the behavior of your application to minimize impact on the device and other applications.

You retrieve device information using the GetValue or the TryGetValue method, as shown in the following code example.

C#
using Microsoft.Phone.Info;

string manufacturer = DeviceExtendedProperties.GetValue(
“DeviceManufacturer”).ToString();
string deviceName = DeviceExtendedProperties.GetValue(
“DeviceName”).ToString();
string firmwareVersion = DeviceExtendedProperties.GetValue(
“DeviceFirmwareVersion”).ToString();
string hardwareVersion = DeviceExtendedProperties.GetValue(
“DeviceHardwareVersion”).ToString();
long totalMemory = Convert.ToInt64(
DeviceExtendedProperties.GetValue(“DeviceTotalMemory”));
long memoryUsage = Convert.ToInt64(
DeviceExtendedProperties.GetValue(
“ApplicationCurrentMemoryUsage”));
object tryValue;
long peakMemoryUsage = -1;
if (DeviceExtendedProperties.TryGetValue(
“ApplicationPeakMemoryUsage”,out tryValue))
{
peakMemoryUsage = Convert.ToInt64(tryValue);
}
// The following returns a byte array of length 20.
object deviceID = DeviceExtendedProperties.GetValue(
“DeviceUniqueId”);

The device ID is a hash represented as an array of 20 bytes, and is unique to each device. It does not change when applications are installed or the firmware is updated.

When running in the emulator, the manufacturer name returns “Microsoft,” the device name returns “XDeviceEmulator,” and (in the initial release version) the hardware and firmware versions return 0.0.0.0.

For more information, and a list of properties for the Device ExtendedProperties class, see “Device Information for Windows Phone” on MSDN (http://msdn.microsoft.com/en-us/library/ff941122(VS.92).aspx).

 

Previous articleContacts and Messaging
Next articleLocation and Mapping

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest News

Underlight As Accent, For Power and The Main Light for Photography

Underlighting, in which fill or accent light comes from under the topic, is not widely used technique in the traditional Portraits,...

How To Fix Overexposure As A Creative Tool, The Complete Guide

As an creative tool, overexposure is sort of underrated. What I’m close to propose could be a deliberate and well thought out technique for...

7D Mark II is Canon’s best DSLR cameras without full-frame sensor.

The expected long-awaited Canon EOS 7D Mark II are shipping in November for $ 1,799 without a lens. With a higher price tag, you...

Low key photography and How to isolate your subject.

Low key photography doesn’t depend on underexposure to make its point; the key to low key is that the majority of tones, even correctly...

High Key Lighting Techniques for Professional Photographers

I’ve written many times about high key lighting techniques and how to achieve them. The term “high key” is a bit misleading. As I’ve...

More Articles Like This