Android Question finding the android ID on the device..

Derek Jee

Active Member
Licensed User
Longtime User
Hello

Can the android_id be found when navigating the device though the settings menu on the device.. I want to get the device id and be able to see the same id on the device somewhere. I got the id in code but cannot correlate it to any ids I see.. I have a Galaxy Tab S.. Thanks,

(The idea is to use a unique id for each device in a database to authenticate a user logging in)


Derek.
 

Derek Jee

Active Member
Licensed User
Longtime User
or is there a different ID I can use which I can get through code AND see on the device somewhere?
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
It is a problem it seems. Yes I can get an id and show it from the app but would have loved to be able to identify the device without having an app installed first. My client wants to distribute these devices to users. When you suggest store an id are you saying in a text file or db somewhere or is there an area I can store an id in the android architecture? I guess I could use the device name except that can be changed too easily by the user.. I suppose on install I can generate a unique id in my db, show it to the installer user and then they can register the device in the main database.. Just thinking aloud..

Thanks Erel..

Derek.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I meant that on the first run you can create a text file with the random id:
B4X:
Sub GetId As Int
 If File.Exists(File.DirInternal, "id.txt") Then
  Return File.ReadString(File.DirInternal, "id.txt")
 Else
  Dim id As Int = Rnd(1, 2147483647)
  File.WriteString(File.DirInternal, "id.txt")
  Return id
 End If
End Sub
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
Thanks Erel.. I just tweaked that idea and wanted to store on my local db.. I like both ideas.. :)

Derek..
 
Upvote 0

pjetson

Member
Licensed User
Longtime User
If your devices have phone capabilities, you can get the IMEI using this code:
B4X:
Dim pid As PhoneId
Dim x As String
x = pid.GetDeviceId

The IMEI should be unique.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
My client wants to distribute these devices to users.
Then your customer has the phone and can write down the IMEI from them and store in DB before distributing to users...
I´m doing the same in my Databasebridge (php-script which do the databasequery and result back json to the app) using the IMEI to identify a device. imei is linked to useraccount to the script knows which user is accessing the db through this php-script.

The IMEI should be unique.

IMEI is a good way and it´s unique as far as i know.

Please remember that a user may have more than one Device he want to use the app on...
You database should be designed to store multiple IMEIs for one customer.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Then your customer has the phone and can write down the IMEI from them and store in DB before distributing to users...
I´m doing the same in my Databasebridge (php-script which do the databasequery and result back json to the app) using the IMEI to identify a device. imei is linked to useraccount to the script knows which user is accessing the db through this php-script.



IMEI is a good way and it´s unique as far as i know.

Please remember that a user may have more than one Device he want to use the app on...
You database should be designed to store multiple IMEIs for one customer.
It is a known issue on some custom ROMs to have the IMEI changed to some bizarre number or just disappear... And there are ways, on rooted phones, to change the Imei value this is NOT hardware dependant, as the device serial number is...
My best guess would be to get the MAC address of one of the adaptors, as these are in fact unique and impossible to change.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
It is a known issue on some custom ROMs to have the IMEI changed to some bizarre number or just disappear

All devices in our company do show the correct IMEI so it is ok for me in our case.
ALL apps i write are for companyintern use and are NOT published on Google Play.

But thanx for your answer.
 
Upvote 0

pjetson

Member
Licensed User
Longtime User
My best guess would be to get the MAC address of one of the adaptors, as these are in fact unique and impossible to change.

MAC addresses are non-unique on many cheaper devices because the manufacturers don't want to pay for a set of numbers. In fact, I've seen several devices where the whole product run had the same MAC address, and other devices where the MAC address was all zeros.

The MAC address can be easily changed on many ethernet devices.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
MAC addresses are non-unique on many cheaper devices because the manufacturers don't want to pay for a set of numbers. In fact, I've seen several devices where the whole product run had the same MAC address, and other devices where the MAC address was all zeros.

The MAC address can be easily changed on many ethernet devices.
I tried to use the MAC address in the past, but I quickly realized that on some (all?) devices the value was incorrect when the Wifi was not turned on.

A useful link on the subject:
http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id
 
Last edited:
Upvote 0

wonder

Expert
Licensed User
Longtime User
I was reading this thread and I came up with the following logic:

How do you identify one person?
You have two basic options. Either you test their DNA for a match or you rely on a set of characteristics that will give you a high level of confidence on identifying this person. Characteristics like, full name, address, date of birth, occupation and visual appearance.
Of course the only way to know for sure that your friend is not a reptilian alien with all the right answers is to have his DNA tested.

How do you identify a device?
Androids have no DNA, however we could implement the same kind of logic. Ask the device a few questions and given a high confidence level, proceed to give authorization.

Since it's a slow Sunday, I came up with two diagrams.
Please forgive my paint skilzzz... :D

 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
MAC addresses are non-unique on many cheaper devices because the manufacturers don't want to pay for a set of numbers. In fact, I've seen several devices where the whole product run had the same MAC address, and other devices where the MAC address was all zeros.

The MAC address can be easily changed on many ethernet devices.
The fact that some devices share the same Mac address may be due to the fact that they "share" the same chip. MAC changing technics are not at reach for the common user I think.



I tried to use the MAC address in the past, but I quickly realized that on some (all?) devices the value was incorrect when the Wifi was not turned on.

I guess some devices will power off some hardware as battery saving thecnic, an unpowered chip cannot provide info.
 
Upvote 0
Top