Device ID's

Good evening all,
Does anyone know how I can calculate a device ID? I'm looking for code that's cross-platform for FMX. I basically need to identify different devices based on their hardware, or alternatively some static ID/GUID that's specific to an OS installation (something that would only change when the OS was reinstalled). For PC's, I can probably use the HDD serial or such, but for mobile I've no idea what I can calculate it from. I could probably go by device serial number, but I've no idea how to gather that.

As I said, the code needs to be cross-platform, but I'm not opposed to using IFDEFs if needed. I'm looking primarily at Windows and Android, but I'd also appreciate OS X and iOS examples as well just to support all 4 platforms.

Any ideas?
0
Scott
11/5/2013 8:49:32 PM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

4 Replies
9339 Views

Similar Articles

[PageSpeed] 8

Scott Pritchard wrote:

> As I said, the code needs to be cross-platform, but I'm not opposed to using IFDEFs if needed. I'm looking primarily
> at Windows and Android, but I'd also appreciate OS X and iOS examples as well just to support all 4 platforms.

With iOS, you can no longer obtain an ID unique to the hardware that will never change. You can however obtain an ID
that is unique for your application, namely:

{code}
uses
  iOSApi.UIKit;

var
  Device: UIDevice;


Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
ID := string(Device.identifierForVendor.UUIDString.UTF8String);
{code}  

-- 
Dave Nottage [TeamB]
Find tips and code samples at Delphi Worlds: 
http://delphi.radsoft.com.au/blog
0
Dave
11/5/2013 11:58:41 PM
> {quote:title=Dave Nottage wrote:}{quote}
> Scott Pritchard wrote:
> 
> > As I said, the code needs to be cross-platform, but I'm not opposed to using IFDEFs if needed. I'm looking primarily
> > at Windows and Android, but I'd also appreciate OS X and iOS examples as well just to support all 4 platforms.
> 
> With iOS, you can no longer obtain an ID unique to the hardware that will never change. You can however obtain an ID
> that is unique for your application, namely:
> 
> {code}
> uses
>   iOSApi.UIKit;
> 
> var
>   Device: UIDevice;
> 
> 
> Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
> ID := string(Device.identifierForVendor.UUIDString.UTF8String);
> {code}  
> 
> -- 
> Dave Nottage [TeamB]
> Find tips and code samples at Delphi Worlds: 
> http://delphi.radsoft.com.au/blog

Thanks for that. I don't suppose anyone's got anything for Android? I considered trying to grab the IMEI, but found that'd only work on phones. I then considered wifi MAC address, but found that'd fail if wifi was disabled (which is a shame since there's already a part-translation of the wifimanager unit available). Further reading indicates this might not be true, but I can't go based purely on speculation. There is a standard Android ID ("Secure.ANDROID_ID") that doesn't require any special permissions,
 but that can be null and can be changed on rooted devices.

I then came across a psuedo-unique ID: http://www.pocketmagic.net/2011/02/android-unique-device-id/
This basically uses hardware ID's for the device to calculate an ID. This is what I'm after as it'd essentially allow me to offer users a seamless experience with 'reconnecting' to my service if they should reset their device (obviously with security in mind, my app would still ask for login details). It does state that it's sometimes possible to have multiple devices with the same ID, but I could always add in some custom parameters such as a user-specified name for the device (and I'm already calculatin
g a PBKDF2-based user id during the signup process so I could always use that as well).

The article doesn't specify any special permissions as being needed to read these ID's, so I've no idea where to even start looking to read that data (if it's even possible to do so in Delphi/FMX). Any ideas?
0
Scott
11/7/2013 3:58:36 PM
Take a look at the DeviceInfo sample from RAD Studio:

C:\Users\Public\Documents\RAD Studio\12.0\Samples\MobileCodeSnippets\DeviceInfo

You will see there how to access to the "Build" class.

> {quote:title=Scott Pritchard wrote:}{quote}
> > {quote:title=Dave Nottage wrote:}{quote}
> > Scott Pritchard wrote:
> > 
> > > As I said, the code needs to be cross-platform, but I'm not opposed to using IFDEFs if needed. I'm looking primarily
> > > at Windows and Android, but I'd also appreciate OS X and iOS examples as well just to support all 4 platforms.
> > 
> > With iOS, you can no longer obtain an ID unique to the hardware that will never change. You can however obtain an ID
> > that is unique for your application, namely:
> > 
> > {code}
> > uses
> >   iOSApi.UIKit;
> > 
> > var
> >   Device: UIDevice;
> > 
> > 
> > Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
> > ID := string(Device.identifierForVendor.UUIDString.UTF8String);
> > {code}  
> > 
> > -- 
> > Dave Nottage [TeamB]
> > Find tips and code samples at Delphi Worlds: 
> > http://delphi.radsoft.com.au/blog
> 
> Thanks for that. I don't suppose anyone's got anything for Android? I considered trying to grab the IMEI, but found that'd only work on phones. I then considered wifi MAC address, but found that'd fail if wifi was disabled (which is a shame since there's already a part-translation of the wifimanager unit available). Further reading indicates this might not be true, but I can't go based purely on speculation. There is a standard Android ID ("Secure.ANDROID_ID") that doesn't require any special permission
s, but that can be null and can be changed on rooted devices.
> 
> I then came across a psuedo-unique ID: http://www.pocketmagic.net/2011/02/android-unique-device-id/
> This basically uses hardware ID's for the device to calculate an ID. This is what I'm after as it'd essentially allow me to offer users a seamless experience with 'reconnecting' to my service if they should reset their device (obviously with security in mind, my app would still ask for login details). It does state that it's sometimes possible to have multiple devices with the same ID, but I could always add in some custom parameters such as a user-specified name for the device (and I'm already calculat
ing a PBKDF2-based user id during the signup process so I could always use that as well).
> 
> The article doesn't specify any special permissions as being needed to read these ID's, so I've no idea where to even start looking to read that data (if it's even possible to do so in Delphi/FMX). Any ideas?
0
Borja
11/7/2013 8:52:04 PM
> {quote:title=Borja Serrano wrote:}{quote}
> Take a look at the DeviceInfo sample from RAD Studio:
> 
> C:\Users\Public\Documents\RAD Studio\12.0\Samples\MobileCodeSnippets\DeviceInfo
> 
> You will see there how to access to the "Build" class.
> 
> > {quote:title=Scott Pritchard wrote:}{quote}
> > > {quote:title=Dave Nottage wrote:}{quote}
> > > Scott Pritchard wrote:
> > > 
> > > > As I said, the code needs to be cross-platform, but I'm not opposed to using IFDEFs if needed. I'm looking primarily
> > > > at Windows and Android, but I'd also appreciate OS X and iOS examples as well just to support all 4 platforms.
> > > 
> > > With iOS, you can no longer obtain an ID unique to the hardware that will never change. You can however obtain an ID
> > > that is unique for your application, namely:
> > > 
> > > {code}
> > > uses
> > >   iOSApi.UIKit;
> > > 
> > > var
> > >   Device: UIDevice;
> > > 
> > > 
> > > Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
> > > ID := string(Device.identifierForVendor.UUIDString.UTF8String);
> > > {code}  
> > > 
> > > -- 
> > > Dave Nottage [TeamB]
> > > Find tips and code samples at Delphi Worlds: 
> > > http://delphi.radsoft.com.au/blog
> > 
> > Thanks for that. I don't suppose anyone's got anything for Android? I considered trying to grab the IMEI, but found that'd only work on phones. I then considered wifi MAC address, but found that'd fail if wifi was disabled (which is a shame since there's already a part-translation of the wifimanager unit available). Further reading indicates this might not be true, but I can't go based purely on speculation. There is a standard Android ID ("Secure.ANDROID_ID") that doesn't require any special permissi
ons, but that can be null and can be changed on rooted devices.
> > 
> > I then came across a psuedo-unique ID: http://www.pocketmagic.net/2011/02/android-unique-device-id/
> > This basically uses hardware ID's for the device to calculate an ID. This is what I'm after as it'd essentially allow me to offer users a seamless experience with 'reconnecting' to my service if they should reset their device (obviously with security in mind, my app would still ask for login details). It does state that it's sometimes possible to have multiple devices with the same ID, but I could always add in some custom parameters such as a user-specified name for the device (and I'm already calcul
ating a PBKDF2-based user id during the signup process so I could always use that as well).
> > 
> > The article doesn't specify any special permissions as being needed to read these ID's, so I've no idea where to even start looking to read that data (if it's even possible to do so in Delphi/FMX). Any ideas?

Fantastic! I should have looked through the included demos first perhaps ;)

For others, the demo makes use of the AndroidAPI.JNI.Os unit and then uses;
{code}JStringToString(TJBuild.JavaClass.MODEL);{code}

The JavaClass has a several hardware specific properties;
 - BOARD
 - BOOTLOADER
 - CPU_ABI
 - CPU_ABI2
 - DEVICE
 - DISPLAY
 - FINGERPRINT
 - HARDWARE
 - HOST
 - ID
 - MANUFACTURER
 - MODEL
 - PRODUCT
 - RADIO
 - SERIAL
 - TAGS
 - TIME
 - &TYPE
 - UNKNOWN
 - USER

Most of these are JStrings except TIME which is Int64, and so you just use IntToStr instead of JStringToString. TIME also appears to be a static value on the device (and it's epoch time in milliseconds) - it doesn't change as the time on the device changes. On my Nexus 5, this time is early in the morning on October 30th 2013 (GMT) so I can only assume that is the time the OS was installed or first initialized after install (I received the phone on the 5th of November, so I suppose it's theoretically poss
ible it got shipped from factory to me in the UK in that timeframe).
0
Scott
11/8/2013 4:46:49 AM
Reply:

Similar Artilces:

Send Message to user's Skype' id ,MSN' Id ,Yahoo'sID or Gmail ID.
hi, i m writing a application in which i have to notify the user to his Skype' id ,MSN' Id ,Yahoo'sID or Gmail ID. Please let me know the code usign C#   Thanks Tulika. hi, what do you want to do...i mean....do you wnat to send email's or do you want to send message to the messenger. thanks, rajiv hi i want to send IM messages to online and offline users not Email. Please help me....

Master page id's and rendered id's not matching up
Hi all, I've got a question... I'm pretty new to masterpages and have a simple one setup that looks like this.<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Simple test</title></head><body>    <form id="form1" runat="server">    <strong>form</strong>    </form></body></html>however when I view the rendered source code the form line looks like this<form name="aspnetForm"...

Session ID's in the URL's
on my company site the session ID's are in a URL. For ex: http://localhost/test.asp?SessionID=05000010066C5DEEF-5045-43D5-9771-3ED6 what does that mean? does that mean that they are not using the client side cookies? and are passing the session in the URL.   That is exactly what it means   but I think this is not the format when the session is not using the cookies, in that case the session is in a format like http://localhost/(000000000000000000)form.aspx I think you are confusing two things here.  The localhost url you showed me appears to be an IIS 7 compati...

Replace 1's and 0's in a gridview column with Yes's and No's
Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.  Thanks One way you can do is thrrough  CASE in your select statement: Select YesNoColumn= CASE yourColumn WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END FROM YourtableLimno <Columns>     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField"> ...

It's Linux !? No, it's BSD ! No, no, it's...
kFreeBSD http://wiki.debian.org/Debian_GNU/kFreeBSD a Debian distro using the FreeBSD kernel ! ObiWan wrote: > kFreeBSD > > http://wiki.debian.org/Debian_GNU/kFreeBSD > > a Debian distro using the FreeBSD kernel ! Why use a BSD kernel? I hope the reason is more than, just because they can. http://wiki.debian.org/Debian_GNU/kFreeBSD_why It's easy to understand why the would want to use Debian packages. :) -- Jimmy Johnson Registered Linux User #380263 >> kFreeBSD >> >> http://wiki.debian.org/Debian_GNU/kFreeBSD >> ...

Unique device ID's
Right now the only mobile devices we use are Blackberry handhelds.  The Blackberry Enterprise Server/MDS can be configured so it places the device's PIN (a unique number for each device) in the http headers.  This can be retrieved with Request.ServerVariables["HTTP_RIM_DEVICE_ID"]. Do any of the other mobile devices, such as Smartphone, etc. provide a similar unique ID through HTTP headers?   Me to cannot get deviceid from asp.net 2.0 mobile application;  maybe you can develop one client application; this app get a deviceid and send to asp.net application... is i...

Standardization of Device API's and Web API's
In the current development phase of B2G, the device API's and Web API's are not as per the standardized API's under consideration by the W3C. I would like to know, in the future plan of B2G development, will there be a standardization of the API's with respect to W3C standards release. ...

Giving Mime.822's unique id's
--____GXXZLPJNHDLBQPBCEYTU____ Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Is there a setting to tell GroupWise to give each mime.822 file a unique = ID? I have to do it manually for spam processing, and it would be spiffy if I = could just save em as is without renaming each one. Thanks! Seth Longmire --____GXXZLPJNHDLBQPBCEYTU____ Content-Type: multipart/related; boundary="____FNOEDJJDGGVOMNDOPUMW____" --____FNOEDJJDGGVOMNDOPUMW____ Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-p...

Getting the recreated control's id's by viewstate?
Hi How can i get the automaticly created fileupload control's id's by stroring them in the viewstate? Is it possible? or any other way to get them on the run-time? I can store button's click number and then create dynamic controls on the run-time and if i look at the source code i can see the auto-created id's but when i click submit button to upload files in fileupload controls i get an NullReferenceException. I guess when i click submit button all the id's gone because the page posts back. So i write this to read id's and assign to my fileupload control, here is the code for it...

superreview requested: [Bug 208744] [FIX]Any attribute 'id' in an XHTML document acts as an id : [Attachment 133558] updated to caillon's comments
Boris Zbarsky <bzbarsky@mit.edu> has asked Peter Van der Beken <peterv@propagandism.org> for superreview: Bug 208744: [FIX]Any attribute 'id' in an XHTML document acts as an id http://bugzilla.mozilla.org/show_bug.cgi?id=208744 Attachment 133558: updated to caillon's comments http://bugzilla.mozilla.org/attachment.cgi?id=133558&action=edit ...

superreview granted: [Bug 208744] [FIX]Any attribute 'id' in an XHTML document acts as an id : [Attachment 133558] updated to caillon's comments
Peter Van der Beken <peterv@propagandism.org> has granted Boris Zbarsky <bzbarsky@mit.edu>'s request for superreview: Bug 208744: [FIX]Any attribute 'id' in an XHTML document acts as an id http://bugzilla.mozilla.org/show_bug.cgi?id=208744 Attachment 133558: updated to caillon's comments http://bugzilla.mozilla.org/attachment.cgi?id=133558&action=edit ------- Additional Comments from Peter Van der Beken <peterv@propagandism.org> So do you want to do the GetID change too? And is the comment at http://lxr.mozilla.org/seamonkey/source/content/ba...

how to get remote device's MAC address by it's IP
HiAnyone knows how to get remote device's MAC address by it's IP, the remote devices are change every 5 minutes, I cannot count on ARP cache.Ben You might get a response in a different forum. this is for a project called "dotnetnuke"-DarrenNeese.com-DNN ROCKS!-DeveloperSchool.com...

Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!
I write a datagrid's ItemDataBound method as follows:   private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)  {   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)   {    if(!isRole("Manager"))    {     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");     if(tmp.Text == "Passed")     {      ((LinkBu...

NSS device/partition ID's
Should my Device ID's and Partition ID's as shown in NSSMU be the same across cluster nodes? I'm experimenting with a NW6.5 cluster. When i add a new LUN on the san, a "cluster scan for new devices" does not pick up the new luns. Should it? If i do an F2-Scan in NSSMU on each node, it does find the new LUN. But the device id is different on each node. Partitions created also have differed id's. Is this normal or should i be concerned? -- rdejean ------------------------------------------------------------------------ Device ID's wil...

Web resources about - Device ID's - embarcadero.delphi.firemonkey

Resources last updated: 1/21/2016 5:47:11 PM