0

I'm trying to get android unique id i'm using this code to get android unique id

String phoneID = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);

when i use this code on sdk version 2.3 on emulator it work fine and return randomly generated android id, but when i use similar code in sdk version 2.0 it will return null,

i try this code also but same result,

String phoneID = System.getString(getContext().getContentResolver(), System.ANDROID_ID);

is there any another way to get android unique id? I'm testing my application on emulator.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

1

See Stackoverflow - how-to-find-serial-number-of-android-device for other ways of getting unique ID for android device. Seva's comment contains info about why you're getting a NULL for ANDROID_ID:

This ID comes from the Google account associated with the phone. The simulator typically does not have one. A real phone might not have one, either. Also, it's documented as "can change upon factory reset", and it can be changed arbitrarily anytime on a rooted phone.

Cœur
  • 37,241
  • 25
  • 195
  • 267
typo.pl
  • 8,812
  • 2
  • 28
  • 29