Build Number of Android device is unique or not? - java

I attached the image to complete understanding of my question.
Image of Build Number of my android device
I have pointed out the build number of my android device.
Here is my 2 question.
1) Is it unique for every device or it can be same?
2) if it is unique how we can get it programmatically?

In order to uniquely identify a device you can use the Secure class in which is part of the Android's Settings package. which returns the Android ID as n unique 64-bit hex string. This way:
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
However, this is non to be null sometimes. An all perfect complete solution to uniquely identify a device is yet to come up. There are various factors to be considered while acquiring the unique id of a device. Also see this Answer

Related

How to predict NFC ID on Android device

does anyone know how I can predict the next id on my android device. Because every time I go over the reader, I get a different id.
It's random by design for security purposes because the design of NFC is that the ID only has to be different if multiple Tags are presented at the same time (NFC != RFID)

How to get Android Serial or Android ID from Setting menu (or somewhere else in the UI)

I obtained the Android serial number by code using
android.os.Build.SERIAL
I then compare it to the serial number found in the Settings menu (Settings-> About device-> Status-> Serial number).
I've tested it, and it seems that on some devices (e.g. Nexus) the two codes are the same, while on others (e.g. Galaxy Note) the two codes are completely different: The Java code returns me a 16-digit alphanumeric (lowercase) code, while on screen I can see an 11-digit alphanumeric (uppercase) code.
How is it possible? Are these two codes the same, or something completely different?
If they are the same, is there a way to convert from one of the two to the other?
Is there a better way to identify the device? I know that I can use 
the phone device ID (IMEI, MEID,...), which can be obtained
TelephonyManager tManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
tManager.getDeviceId();
but not all devices are phones, and not all of them have this code;
The Android ID, retrievable by
Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);
But I cannot find it anywhere in the Settings menu, and I need my user to tell me its code by reading it from the user interface.
The app "Android id" on google play(free) shows different ID's like:
android_ID
android.os.build.serial
telephonyManager deviceID
wifi mac

Is telephony manager values reliable and changeable (cdma)?

I want to know if I can rely on the telephony values like country, MCC, etc on Android for my app. Can I change them on the run using setprop? I tried changing using setprop it didn't seem to work. From my understanding telephony manager is a class/interface which represents Hardware configuration of GSM or CDMA. In case of GSM this could be sim and in case of CDMA it cud be a hardware. My questions are:
Who update these values in both the cases for the first time?
Are these values are saved by OS as read only?
What if a user travels to different country or zone will some of the values like country code and MCC values updated automatically?
Can I reset these values?
I have no intention of changing any of these values but want to understand its working! I would appreciate if someone can help me on this.
According to android documentation
Provides access to information about the telephony services on the
device. Applications can use the methods in this class to determine
telephony services and states, as well as to access some types of
subscriber information. Applications can also register a listener to
receive notification of telephony state changes.
TelephonyManager is used for reading phone information. Regarding your question about MCC & MNC codes: yes, they will change when phone will be in other country. You can subscribe to receive those events and determine that user now in different country.
#Bo
The way CDMA works is different from GSM. CDMA has always got one home base and many visitor base location. and you can always get to know about visitor Operator using TelephonyManager methods which is considered as unreliable for CDMA.
I decided to add it as answer as well...
I found a way to tackle this problem on CDMA phone.. if it is a CDMA phone , then the phone always has an ICC hardware comparable to SIM cards in GSM. All you gotta do is use the system properties associated with the hard ware . Programmatically you can use Java reflection to get this information . This is not changeable even system is rooted unlike GSM device. Class c=Class.forName("android.os.SystemProperties"); Method get = c.getMethod("get", String.class); String homeOperator = ((String) get.invoke(c, "ro.cdma.home.operator.numeric"));

Generating ID unique to a particular computer [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Reliable way of generating unique hardware ID
Am trying to generate an ID that will be unique to a particular computer. The ID will not be generated randomly. It will be calculation based, such that the ID generated for computer A will be fixed and unique to computer A. Everytime the program is executed on computer A, it will continue to generate the same ID and when executed on another computer, it will generate another ID unique to that computer. This is to ensure that two computers don't have the same ID.
My Challenge: For my program to be able to generate an ID unique to a computer, it needs to perform the calculation based on a seed unique to the computer executing it.
My Question: How can i get a value unique to a computer, so that i can use the value as a seed in the ID generation program?
Is it possible to get a value from a computer's hardware(eg motherboard) that is unique to that computer? That way, the value is most likely not to change as long as the computer's motherboard is not replaced.
MAC address? Thats (for practical purposes) unique to every NIC so it guarantee's reproducibility even if the user is dual booting. Sure there are rare cases of people trading cards, but coupled with other metrics (don't only use this, since network cards can be changed), it's still possible.
How would you get it?
public static byte[] getMACAddress() throws SocketException, UnknownHostException {
InetAddress address = InetAddress.getLocalHost();
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(address);
return networkInterface.getHardwareAddress();
}
If you want a String representation, do this
for (int byteIndex = 0; byteIndex < macAddress.length; byteIndex++) {
System.out.format("%02X%s", macAddress[byteIndex], (byteIndex < macAddress.length - 1) ? "-" : "");
}
(thanks to http://www.kodejava.org/examples/250.html)
Note: As mentioned in the comments, Mac addresses can be spoofed. But your talking about a small part of the population doing this, and unless your using this for anti-piracy stuff, its unique enough.
Win32 generates a computer SID, that is supposed to be unique for each installation that you can get via WMI or Active Directory, but that is pretty platform specific. You can also use the MAC address, as everyone else has mentioned, just make sure that it is a physical network adapter, as virtual adapters tend to share the same MAC address across computers.
However, UUID's (or GUID's) are 128 bit numbers that are supposed to be guaranteed unique, and were actually created for the purpose of solving the problem of generating unique identifiers across multiple, random machines. According to Wikipedia:
To put these numbers into perspective,
one's annual risk of being hit by a
meteorite is estimated to be one
chance in 17 billion,[25] that means
the probability is about 0.00000000006
(6 × 10−11), equivalent to the odds of
creating a few tens of trillions of
UUIDs in a year and having one
duplicate. In other words, only after
generating 1 billion UUIDs every
second for the next 100 years, the
probability of creating just one
duplicate would be about 50%. The
probability of one duplicate would be
about 50% if every person on earth
owns 600 million UUIDs.
The total number of possible combinations is 2^128 (or 3 x 10^38), so I tend to believe it. Also, most modern UUID generators don't use the V1 algorithm anymore (i.e. the one based off the MAC address), since it is considered a security issue due to the fact that one can tell when the GUID was generated, and who generated it. In the Win32 world, a security patch circa Win2K or NT 4 changed to use the V4 version of the algorithm, which is based off of a pseudo-random number instead of the MAC, and the JVM has always used the V3/V4 version.
EDIT: The method used to generate UUID's in Java is via the java.util.UUID class.
An easy way to do this is to read the ethernet hardware, or "mac" address.
http://download.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()
Mac addresses are not quite as unique as people think, as they do get reused as time goes on. But the odds of one application or network having two identical ones are quite low.
The MAC address is unique enough for what you. See http://en.wikipedia.org/wiki/MAC_address
You didn't specify which language you are using. It may easier in some languages than others. Here is how to do it in Java http://www.kodejava.org/examples/250.html. Google around for your language.
Your best option is to base the ID on the MAC address of the primary network adaptor.
This is potentially likely to change at somepoint, but so is any single hard component.
FYI GUIDs are calculated using the MAC address.
Have you access to any information described in this article? Windows-only
http://msdn.microsoft.com/en-us/library/aa394587.aspx
Serial number, asset tag
Another option IFF you're using intel chips is the processor serial number, assuming you can ensure the feature is enabled. See Intel Serial # Note for more info

Get device unique ID

Is there a way to get a device's unique identification using MIDP2.0?
I assume you need to get the IMEI number of the device.
According to the information I found there is no J2ME method to do that because the Hardware API is different from a one model to another. But the device manufacturers provide APIs to get the IMEI number.
Have a look on following article.
Get device ID

Categories