How to uniquely identify android device to track devices - android

Hello I am working on an application in which we are tracking our app installation using device unique ID.
We are doing right now like this as https://stackoverflow.com/a/2785493/2455259
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
I got to know that from android 4.2 it can have different for different users https://stackoverflow.com/a/27013749/2455259.
Now I can't take mac address of wifi or bluetooth because it requires to make it turn on then fetch. Even I can't take IMEI because some tables don't have call feature so they don't have IMEI.
Now what are the option to uniquely identify android device ?

Now what are the option to uniquely identify android device ?
I am afraid assigning own unique number is most effective approach, because ANDROID_ID is broken (the answer you link to is incorrect - see comments there too), relying on it is quite futile as it can sometimes be the same for many devices or null, so anything but unique, therefore using it is pointless as it adds more troubles than helps. There's post on Android blog about this topic "Identifying App Installations" that you may want to get thru as well.

I know this is old and the OP might have already moved on but with the introduction of Instance ID, we can use it to identify a unique installation.
The associated code is pretty straightforward too.
String iid = InstanceID.getInstance(context).getId();
The benefits include not having to specify permissions for Android Marshmallow and above. This seems to be a plus for developers who would need a unique id at the outset and cannot rely on user provided permission model for the same.

Related

Cambridge Scientific - Tablet - IMEI clash

I'm after some help - I've noticed that some Cambridge Scientific StarPADs have an IMEI clash when we check for Unique ID.
((TelephonyManager)paramContext.getSystemService("phone")).getDeviceId();
or
Settings.Secure.getString(paramContext.getContentResolver(), "android_id");
I'm at a bit of a loss, the supplier is claiming ignorance and it is discussed elsewhere Id Android Apps .. does anyone out there have any ideas?
BTW: Yes I've checked around for a similar question, but if I've missed something - happy to be corrected.
Because of Android fagmentation there is no Unique ID in Android at all.
If You really need it for backend use, you should create at backend side new ID while app first start and store it ex. in SharedPreferences.
If You want this key to persist between instalations problem is more complicated. You may store this key out of /data/data/ directory but it's a bit hacky method.
Another solution is to generate potential unique ID by getting as many id's from Your phone as You can get. WiFi mac address, Bluetooth mac address, device ID etc. and combine them but you can never be sure it will be unique globally.

How to get unique id for clients without registration? (Jodel app for e.g)

Imagine an application that consists of loads of clients and one server. The clients should be able to use the application without the need to register a username for e.g. (Therefore getting the feeling of anonymously using the app)
What unique data in a smartphone could be use to identify "anonymous" users and seperate them uniquely, so that each user would have its own personal data.
Could one use the IMEI id?
Is this possible?
At I/O 15 Google announced the 'instance ID' which uniquely identifies an app installation, and can be used for a veriety of other purposes as well.
I give more detail in an answer to an existing, similar question here:
https://stackoverflow.com/a/30948111/150016
Yes You can use the IMEI, but then you need a permission...or you could give every User a Unique ID on the server side
I think a long type variable is enough so the first one that connects you give him the ID 1 the app gets the ID and so on and so forth
You can use a built in feature here:
import android.provider.Settings.Secure;
private String uniqueIdentifier = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
where Secure.ANDROID_ID is presented as "A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device."
This is exactly the use case for the new Instance ID: getting a unique ID that you can use to identify even a not logged in user to your server.
This works on both phones and tablets (something IMEI does not) and avoid issues with ANDROID_ID (such as a few manufacturers always using the same ANDROID_ID on all devices).
You don't want to use the IMEI, as it will only apply to devices that have cell phones in them. There are plenty of wifi only devices out there in the wild.
Also, to get the IMEI, you need to ask for extra permission in your manifest.
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
You'd be better off either generating your own random GUID and storing it in your app's SQLite database, or use the Android ID field.
Android ID will give you extra benefits like providing a different identifier for different user profiles within a device.
Another answer here mentioned using Instance ID, but the big caveat there is it requires Google Play Services, so your app wouldn't work on AOSP / forked devices (i.e. Amazon's tablets). I'd have just inserted this as a comment to that answer, but my rep won't let me comment yet.

Verify a user identity via Phone Number or other unique ID (iOS/Android)

Following scenario:
I want to create an wifi hotspot on a public place (e.g. train station). Therefore i want to write an mobile application (iOS and/or Android) which works as a portal page. As I would be providing internet access via my wifi hotspot I need to make sure that people who want to log in verify their identity properly (responsibility). First I thought i could do something like a facebook login but I guess that would not be enough as people can create fake accounts.
Then I got the idea that I could maybe access their telephone number via their smartphones.
I googled alot and came to the conclusion that it is pretty tough on both platforms.
The iOS method seems to be deprecated and apps wont make it to the app store with that version. Android can read the phone number from the sim card, but not all providers store the number on the sim card.
Question
Is there any possibility to get the phone number? Or is there any other way to uniquely identify a person in a wifi network?
Of course I dont want to do any of that without asking for users permission etc...
Greetings and thanks in advance
Peter
Choosing the MAC address is a good choice, it is not the safest, but it is the more easy to do.
The IMEI is not always provided, and the SERIAL is not uniq.
But actually, I don't know how to do this with iOS.
What is about the MAC address of the phone? This should be unique enough and you can get is easily from android and from iOS.
Android: http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getMacAddress%28%29
iOS: How can I programmatically get the MAC address of an iphone
Using IMEI number
Android Does provide functions/method to access device IMEI number
First Set <uses-permission android:name="android.permission.READ_PHONE_STATE" />
in android manifest
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
Hope it helps
For NON CDMA or GSM devices like Tablet
Use
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
This would generate a unique code for the device..how ever it would change on when user reset the device ie factory reset it .. and it works for device having os > 2.2(froyo)
This really depends on who you are trying to identify. That may seem like an odd response, but usually, we are trying to identify two, not one, sets of credential elements.
First, we want ot identify the device itself -- is this the deivce we expect to see and can we trust that this device has not been tampered with. Second, we usually want to know if the user of this device at the moment is one we expect to be using this, now validated, device. (If I take your phone, without step #2, I just became you.)
This is why we have things like 802.1x. It lets me validate the user of a network, not just the device. For your case, consider something like:
For device validation, the combination of hte MAC address and the IMEI. TUrn those into a unique hash with some data from the user. For example.
ID = SHA1(IMEI+MAC(Wifi)+user password)
Now that we're pretty sure the device and user are correct, if you need to, you can go one step further and use that hash a key to encrypt a user validation step in your app. Even if the user is correct, if they're on the wrong device, their key won't decrypt.

Unique ID for each user in Android

I want to allocate unique ID to each user as soon as he installs the application so that whenever the app contacts the server I know who is contacting.
For this purpose, I thought that on first time installation, the app contacts the server and gets unique ID. But I don't know where to store it permanently so that next time when app is started, it knows what its ID is rather than contacting server.
Sorry if that is some obvious question as I am newbie.
This question has been asked many times on Stack Overflow.
In short: Android has always supported a unique ID. However, prior to Android 2.2, the ID was not always identical on certain kinds of phones. Since 2.2 is pretty ubiquitous by now, I would use that ID.
The Android Developer Blog has a good article about this.
And as Joachim said - you may want to consider a different approach altogether. Android's unique ID is good and persistent across factory resets, but not across a device upgrade. Also keep in mind that many people have several devices (like a phone and a tablet). You may want to use the Google account instead, the AccountManager can help you there.
Use SharedPreferences to store the unique id.
Here is an example:
Android SharedPreferences
For more complex data, you can use SQlite.
For unique id, you can use IMEI of device on which application is going to install. Refer this link for how to get IMEI number. Then stored that IMEI number in shared preference. Refer Guillermo lobar's link for that. You need to check for that unique id in preference when you application starts. At very first time, save that in preference. So when next time it checks for that id, app find it in preference and hence no need to connecting server. :)
You could get the IMEI of the device. As of API 26, getDeviceId() is deprecated. If you need to get the IMEI of the device, use the following:
String deviceId = "";
if (Build.VERSION.SDK_INT >= 26) {
deviceId = getSystemService(TelephonyManager.class).getImei();
}else{
deviceId = getSystemService(TelephonyManager.class).getDeviceId();
}

Android "device name" equivalent

I would like input in deciding what API-accessible field in Android is the best equivalent to an iPhone's "device name" (it will be used as non-essential login data passed to a server). By device name, I do not mean "model", or any hardware- or software-related identifier, but more to do with the owner.
See How do you get an iPhone's device name for exactly what I'm referencing.
As an additional example, when faced with the same problem in BlackBerry, it was decided that the owner name was the best equivalent. (See answer in Get Blackberry Owner details (eg name/number) through API )
So far, it looks to me like the best android-equivalent is using an AccountManager to return someone's google account email; see How can you get an Android user's email address?. This seems to me like a pretty rough approximation, though; and would require adding another whole permission to the app just for some non-essential login data. Does anyone know of a better equivalent, and how to grab it?
Many thanks!
If you look in Settings -> Wireless & Network Setting -> Bluetooth Settings There is an option to set the device name. If the device name has not been set then I think it uses the persons account. You can access it through the BluetoothDevice.getName() method. Not sure if that helps.
BluetoothAdapter.getDefaultAdapter.getName() is also returning null if the user has switched off BT e.g. for saving battery or for security reasons. So it's not reliable, I'd say.

Categories

Resources