android UUID和phonegap设备UUID之间的区别

时间:2013-02-14 10:06:02

标签: android cordova device uuid

谁能告诉我android唯一ID,即UUID和phonegap设备ID UUID之间的区别? 它们是相同还是不同的值? 如果这些值不同,那么两者中是否存在任何唯一的属性值。?

3 个答案:

答案 0 :(得分:5)

<强>更新

从上述两个参数获得的值是不同的。彼此不匹配。

android UUID:

TelephonyManager  manager=(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String uuid=manager.getDeviceId();

android phonegap UUID

- 返回一个随机的64位整数(再次作为字符串!)

- 在设备的首次启动时生成整数

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {

   try {
      var uuid = device.uuid; * * //always use device object after deviceready.**

   } catch (e) {

      alert(e);

   }
}

从我的Android(2.3)手机获取的值为:

android UUID: 354457052232596(16位数)

android phonegap UUID :70a0353498a27a34(16位十六进制数字)

了解有关设备UUID检查的更多信息:

http://docs.phonegap.com/en/1.0.0/phonegap_device_device.md.html

答案 1 :(得分:0)

获取设备的通用唯一标识符(UUID)。

var string = device.uuid;

描述:UUID如何生成的详细信息由设备制造商确定,并且特定于设备的平台或型号。

支持的平台:

  • 的Android
  • BlackBerry WebWorks(OS 5.0及更高版本)
  • iPhone
  • Windows Phone 7和8
  • Bada 1.2&amp; 2.X
  • webOS的
  • Tizen
  • Windows 8

快速示例

// Android: Returns a random 64-bit integer (as a string, again!)
//          The integer is generated on the device's first boot
//
// BlackBerry: Returns the PIN number of the device
//             This is a nine-digit unique integer (as a string, though!)
//
// iPhone: (Paraphrased from the UIDevice Class documentation)
//         Returns a string of hash values created from multiple hardware identifies.
//         It is guaranteed to be unique for every device and cannot be tied
//         to the user account.
// Windows Phone 7 : Returns a hash of device+current user, 
// if the user is not defined, a guid is generated and will persist until the app is uninstalled
// 
// webOS: returns the device NDUID
//
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
// unique to every GSM and UMTS mobile phone.
var deviceID = device.uuid;

答案 2 :(得分:-1)

我有同样的问题。这是明确的解决方案。

HTML Code:

<!DOCTYPE html>
<html>
  <head>
    <title>Device Properties Example</title>

    <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

    <script type="text/javascript" charset="utf-8">

    // Wait for PhoneGap to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // PhoneGap is ready
    //
    function onDeviceReady() {
      alert("checking...");
        var element = document.getElementById('deviceProperties');

        element.innerHTML = 'Device Name: '     + device.name     + '<br />' + 
                            'Device PhoneGap: ' + device.phonegap + '<br />' + 
                            'Device Platform: ' + device.platform + '<br />' + 
                            'Device UUID: '     + device.uuid     + '<br />' + 
                            'Device Version: '  + device.version  + '<br />';
    }

    </script>
  </head>
  <body>
    <p id="deviceProperties">Loading device properties...</p>
  </body>
</html>

config.xml look like
<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns = "http://www.w3.org/ns/widgets"

        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "com.phonegap.example"
        version     = "1.0.0"
        versionCode = "10" >

        <!-- versionCode is optional and Android only -->

        <preference name="phonegap-version" value="3.5.0" />

        <name>kali</name>

        <description>
        An example for phonegap build docs. 
        </description>

        <author href="http://yoursite.com" email="you@youremail.com">
        Your Name
        </author>
<gap:plugin name="org.apache.cordova.device" version="0.2.12" />


    </widget>

You have to add cordova.js

its works fine from my side.