3

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?

Isbister
  • 906
  • 1
  • 12
  • 30

5 Answers5

0

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

Ilja KO
  • 1,272
  • 12
  • 26
0

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."

Jay Snayder
  • 4,298
  • 4
  • 27
  • 53
0

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.

LDMJoe
  • 1,591
  • 13
  • 17
0

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).

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
0

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

Community
  • 1
  • 1
Tom
  • 17,103
  • 8
  • 67
  • 75