一、 获取设备信息的方法列表(如果没有或者检测不出来就显示undefined)
1、device.name 设备名称(一些国产机检测不出来)
2、device.model :返回设备的模型或产品的名称
3、device.cordova PhoneGap 版本
4、device.platform 设备平台
5、device.uuid uuid 编码(这个编码是设备的唯一编码相当于每部手机的身份证,比较常用,项目中就可以通过这个编码跟用户的id进行绑定)
6、device.version 平台版本
二、代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>phonegap_device_network_notification01</title>
<link href="../jquery.mobile-1.3.2.css" rel="external nofollow" rel="stylesheet" type="text/css"/>
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="../cordova.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
document.addEventListener("deviceready", myDeviceReadyListener, false);
}); function myDeviceReadyListener(){
$("#deviceName .ui-btn-text").text("设备名称" + device.name);
$("#deviceModel .ui-btn-text").text("设备的模型" + device.model);
$("#deviceCordova .ui-btn-text").text("PhoneGap版本" + device.cordova);
$("#devicePlatform .ui-btn-text").text("设备平台" + device.platform);
$("#deviceUUID .ui-btn-text").text("uuid编码" + device.uuid);
$("#deviceVersion .ui-btn-text").text("平台版本" + device.version);
} </script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>PhoneGap实战</h1>
</div>
<div data-role="content">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="deviceName"></a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="deviceModel"></a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="deviceCordova"></a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="devicePlatform"></a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="deviceUUID"></a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-role="button" id="deviceVersion"></a>
</div>
<div data-role="footer">
<h4> </h4>
</div>
</div>
</body>
</html>