difference between android UUID and phonegap device UUID

邮差的信 提交于 2019-12-22 18:34:01

问题


could anyone tell me the difference between android unique id i.e UUID and phonegap device id UUID? Are they same or different values? If these values different,then is there any unique property value that is same in both.?


回答1:


Update

The values obtain from above two parameters are different.Don't match with each other.

android UUID:

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

android phonegap UUID

--Returns a random 64-bit integer (as a string, again!)

--The integer is generated on the device's first boot

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

function onDeviceReady() {

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

   } catch (e) {

      alert(e);

   }
}

Values obtained from my android(2.3) phone are:

android UUID: 354457052232596 (16 numbers)

android phonegap UUID: 70a0353498a27a34 (16 hexadecimal number)

to more about Device UUID Check :

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




回答2:


Get the device's Universally Unique Identifier (UUID).

var string = device.uuid;

Description: The details of how a UUID is generated are determined by the device manufacturer and specific to the device's platform or model.

Supported Platforms:

  • Android
  • BlackBerry WebWorks (OS 5.0 and higher)
  • iPhone
  • Windows Phone 7 and 8
  • Bada 1.2 & 2.x
  • webOS
  • Tizen
  • Windows 8

Quick Example

// 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:


I had same problem. Here is clear solution.

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.


来源:https://stackoverflow.com/questions/14872257/difference-between-android-uuid-and-phonegap-device-uuid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!