5

I have multiple devices, and I probably will have more, and do not want to add them one by one. Does anybody know what ID Admob uses?

Vikas Patidar
  • 42,865
  • 22
  • 93
  • 106
dongshengcn
  • 6,434
  • 7
  • 35
  • 44
  • looks like same question with no answer here: http://stackoverflow.com/questions/4450425/android-device-id-not-imei – dongshengcn Mar 09 '11 at 17:50

3 Answers3

7
String aid = Settings.Secure.getString(getContext().getContentResolver(), "android_id");

Object obj = null;
try {
    ((MessageDigest) (obj = MessageDigest.getInstance("MD5"))).update(
                                   aid.getBytes(), 0, aid.length());

    obj = String.format("%032X", new Object[] { new BigInteger(1,
                                   ((MessageDigest) obj).digest()) });
} catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
    obj = aid.substring(0, 32);
}

I hope this will help you ;)

user1120696
  • 71
  • 1
  • 2
1

I tried that and it gave me the Hex value for my ESN number. This is not the number AdMob uses.

When requesting an ad, in the Dalvic Debug Monitor log it shows you the number to use.

Also you might want to refer to the following page (about half way down): http://code.google.com/mobile/ads/docs/android/intermediate.html

-1

Hi Note Down My answer ,if you want to get Device id, you can use TelephonyManager as i used below

String device_id=null;
TelephonyManager telemngr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
device_id=telemngr.getDeviceId();

You also need to add the following permission to your manifest:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Adil Malik
  • 6,279
  • 7
  • 48
  • 77