【问题标题】:difference between android UUID and phonegap device UUIDandroid UUID和phonegap设备UUID的区别
【发布时间】:2013-01-30 02:28:39
【问题描述】:

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

【问题讨论】:

    标签: android cordova device uuid


    【解决方案1】:

    更新

    以上两个参数得到的值不同,不匹配。

    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

    【讨论】:

    • ios的udid和phonegaps的uuid一样吗?
    • 恢复出厂设置后PhoneGap获取的UUID会变吗?
    【解决方案2】:

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

    var string = device.uuid;
    

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

    支持的平台:

    • 安卓
    • BlackBerry WebWorks(操作系统 5.0 及更高版本)
    • iPhone
    • Windows Phone 7 和 8
    • Bada 1.2 & 2.x
    • 网络操作系统
    • 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;
    

    【讨论】:

      【解决方案3】:

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

      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.
      

      【讨论】:

      • ios的udid和phonegaps的uuid一样吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-28
      • 2015-08-08
      • 2011-06-24
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 2015-02-03
      相关资源
      最近更新 更多