private static bool IsWvga
{
get { return App.Current.Host.Content.ScaleFactor == 100; }
}
 
private static bool IsWxga
{
get { return App.Current.Host.Content.ScaleFactor == 160; }
}
 
private static bool Is720p
{
get { return App.Current.Host.Content.ScaleFactor == 150; }
}

硬件配置

摄像头(Camera)

#if WINDOWS_PHONE_8   // Windows Phone 8
try
{
BackCameraExist = PhotoCaptureDevice.AvailableSensorLocations.Contains<CameraSensorLocation>(CameraSensorLocation.Back);
FrontCameraExist = PhotoCaptureDevice.AvailableSensorLocations.Contains<CameraSensorLocation>(CameraSensorLocation.Front);
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
}
 
#else // Windows Phone 7
FrontCameraExist = Microsoft.Devices.Camera.IsCameraTypeSupported(Microsoft.Devices.CameraType.FrontFacing);
BackCameraExist = Microsoft.Devices.Camera.IsCameraTypeSupported(Microsoft.Devices.CameraType.Primary);
#endif

闪光灯(Flash)

    if (BackCameraExist)
{
var cam = new Microsoft.Devices.PhotoCamera(Microsoft.Devices.CameraType.Primary);
BackCameraFlashExist = cam.IsFlashModeSupported(Microsoft.Devices.FlashMode.On);
}
 
if (FrontCameraExist)
{
var cam = new Microsoft.Devices.PhotoCamera(Microsoft.Devices.CameraType.FrontFacing);
FrontCameraFlashExist = cam.IsFlashModeSupported(Microsoft.Devices.FlashMode.On);
}

罗盘(Compass)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Compass.GetDefault() != null)
{
CompassExist = true;
}
 
#else // Windows Phone 7
CompassExist = Microsoft.Devices.Sensors.Compass.IsSupported;
#endif

NFC

#if WINDOWS_PHONE_8  // Windows Phone 8
// ID_CAP_NETWORKING ID_CAP_PROXIMITY
if (ProximityDevice.GetDefault() != null)
{
ProximityExist = true;
}
#else // Windows Phone 7
// Windows Phone 7 不支持NFC功能
#endif

陀螺仪(Gyroscope)

#if WINDOWS_PHONE_8  // Windows Phone 8
// 目前Gyrometer.GetDefault()在陀螺仪不支持时会抛出异常,以MSDN文档描述的返回null不符。
try
{
if (Gyrometer.GetDefault() != null)
{
GyroscopeExist = true;
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
 
#else // Windows Phone 7
GyroscopeExist = Microsoft.Devices.Sensors.Gyroscope.IsSupported;
#endif

加速传感器(Accelerometer)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Accelerometer.GetDefault() != null)
{
AccelerometerExist = true;
}
 
#else // Windows Phone 7
AccelerometerExist = Microsoft.Devices.Sensors.Accelerometer.IsSupported;
#endif

磁倾仪传感器(Inclinometer)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Windows.Devices.Sensors.Inclinometer.GetDefault() != null)
{
InclinometerExist = true;
}
 
#else // Windows Phone 7
// Windows Phone 7 不支持
#endif

方向传感器(Orientation)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Windows.Devices.Sensors.OrientationSensor.GetDefault() != null)
{
OrientationSensorExist = true;
}
 
#else // Windows Phone 7
OrientationSensorExist = Microsoft.Devices.Sensors.Motion.IsSupported;
#endif

震动设备(VibrationDevice)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Windows.Phone.Devices.Notification.VibrationDevice.GetDefault() != null)
{
VibrationDeviceExist = true;
}
 
#else // Windows Phone 7
if (Microsoft.Devices.VibrateController.Default != null)
{
VibrationDeviceExist = true;
}
#endif

电量传感器(Battery)

#if WINDOWS_PHONE_8  // Windows Phone 8
if (Windows.Phone.Devices.Power.Battery.GetDefault() != null)
{
BatterySensorExist = true;
}
 
#else // Windows Phone 7
// Windows Phone 7 不支持
#endif

SD卡(SD Card)

#if WINDOWS_PHONE_8 // Windows Phone 8
var devices = await ExternalStorage.GetExternalStorageDevicesAsync();
SDCardExist = (devices != null && devices.Count() > 0);
#else // Windows Phone 7
// Windows Phone 7 不支持SD卡
#endif

内存判断(Memory)

#if WINDOWS_PHONE_8 // Windows Phone 8
MemoryCurrentUsed = Windows.Phone.System.Memory.MemoryManager.ProcessCommittedBytes.ToString();
MemoryMaxAvailable = Windows.Phone.System.Memory.MemoryManager.ProcessCommittedLimit.ToString();
 
#else // Windows Phone 7
// 通过DeviceExtendedProperties类获取
#endif

Windows Phone 应用的功能和硬件要求

在获取设备硬件信息之前,你还 需要在清单文件中标记你的应用需要的功能(CAPABILITIES) 。另外你还 可以在清单文件中指定应用的硬件要求(REQUIREMENTS),以确保只有满足硬件要求的设备才能在应用商店中查看并下载安装你的应用

要了解应用功能和硬件要求,可以在下面链接查看: http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj206936.aspx

应用清单文件

文件路径:工程目录->Properties->WMAppManifest.xml

应用清单文件设计器(Windows Phone 8)

我们可以通过清单文件设计器来标记应用的功能和硬件要求,但是在设计器中不能够标记全部的功能或硬件要求(比如ID_REQ_MEMORY_300),这时你就需要用“查看代码”的方式打开WMAppManifest.xml文件进行编辑。

示例代码

File:HardwareFinder.zip

 
This page was last modified on 18 July

Windows Phone 硬件检测的更多相关文章

  1. Windows下如何检测用户修改了系统时间并且把系统时间改回来

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:Windows下如何检测用户修改了系统时间并且把系统时间改回来.

  2. 星语硬件检测专家 V4.3 官方版

    软件名称: 星语硬件检测专家 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 15.8MB 图片预览: 软件简介: 星语硬件检测专家是一款功能非常强大的硬件 ...

  3. 801硬件检测工具DragonHD的使用

    801硬件检测工具DragonHD的使用 2018/11/28 13:39 版本:V1.0 开发板:SC3817R 1.客户要认证器件,使用了全志官方的工具:DragonHD.exe 打开之后可以见用 ...

  4. linux和Windows双系统让 Windows 把硬件时间当作 UTC

    linux和Windows双系统让 Windows 把硬件时间当作 UTC Windows设置如下:开 始->运行->CMD,打开命令行程序(Vista则要以管理员方式打开命令行程序方可有 ...

  5. DirectX11 With Windows SDK--20 硬件实例化与视锥体裁剪

    前言 这一章将了解如何在DirectX 11利用硬件实例化技术高效地绘制重复的物体,以及使用视锥体裁剪技术提前将位于视锥体外的物体进行排除. 在此之前需要额外了解的章节如下: 章节回顾 18 使用Di ...

  6. windows下脚本检测tomcat是否启动,没有启动则启动

    最近有个服务需要部署到windows server2003上面,机房没有windows ser的机器,没办法搞了个阿里云服务,购买的配置比较低, 不知道什么原因,tomcat启动后总是容易自动退出,搞 ...

  7. USB插入电脑的硬件检测和枚举流程

    USB协议定义了设备的6种状态,仅在枚举过程种,设备就经历了4个状态的迁移:上电状态(Powered),默认状态(Default),地址状态(Address)和配置状态(Configured)(其他两 ...

  8. nagios对windows流量的检测

    windows下用于和 nagios 整合监控的方式主要有三种:nsclient++ .nrpe_nt.SNMP.三者各自的特点主要如下: 1.nsclient++比较成熟稳定,文档也丰富,内置很多了 ...

  9. windows查看硬件信息系统信息

    rem 查看cpu wmic cpu list briefrem 查看物理内存wmic memphysical list briefrem 查看逻辑内存wmic memlogical list bri ...

随机推荐

  1. 暑假热身 E. 无聊的LSY

    LSY大牛没事就爱玩游戏,包括很多很无聊的游戏.某日,LSY大牛又找到了一个无聊的游戏:每一局游戏的开始,LSY大牛将代表自己的棋子放在一个线性棋盘的最左端(第0个格子,可以认为向右端无限延伸),接着 ...

  2. 如何在linux中用命令产生一个范围内的随机数?

    在shell中有一个环境变量RANDOM,它的范围是0--32767 如果我们想要产生0-25范围内的数,如何做呢?如下: $RANDOM%26 用这个环境变量对26取模,就可以得到最小是0,最大是2 ...

  3. python 最佳入门实践

    勿在浮沙筑高台,无论什么技术,掌握核心精神和api,是很重要的. 但是入门过程也可能不是一帆风顺的,这里有八个入门任务,看看你完成了没有: http://code.tutsplus.com/artic ...

  4. nGrinder性能测试平台搭建(LVS压力测试)

    1. nGrinder是什么 nGrinder是一个免费的.开放源代码的Web性能测试平台.运行在应用中间件服务器中运行.它由一个控制端和多个代理端组成.通过控制端(浏览器访问)建立测试场景,然后通过 ...

  5. Find Leaves of Binary Tree

    Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves ...

  6. 【原创】sql:慎用【数字字段1 - 数字字段2】这样的sql(10-null = null)mysql

    如果只有一个表的情况下 a表: id num1,num2 1 10 5 2 10 0 3 20 0 select id, num1,num2,num1 - num2 AS subNum from a; ...

  7. android.content.ActivityNotFoundException: Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?

    在整合PullToRefresh的时候出现如下异常 10-22 23:20:01.826 32331-32331/com.example.news.andoridnewsapp E/AndroidRu ...

  8. Java for LeetCode 201 Bitwise AND of Numbers Range

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  9. input框颜色修该

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...