android get device ID for adMob [duplicate]

筅森魡賤 提交于 2019-12-17 15:44:35

问题


Possible Duplicate:
How can I get device ID for Admob

I am testing adMob on my android device and following with documentation, I am trying to get device ID executing adRequest. However, I am not able to find device ID in the logCat! What I am doing wrong?

 AdRequest adRequest = new AdRequest();
 adRequest.addTestDevice(AdRequest.TEST_EMULATOR);            
 adRequest.addTestDevice("test");     

Edit: it is not a duplicate, those methods from other post are not working for me.


回答1:


 final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

String deviceid = tm.getDeviceId();



回答2:


Make a live ad request while running on the device, and view the logs. There should be a log at the info level that says:

I/Ads: To get test ads on this device, call adRequest.addTestDevice("YOUR_HASHED_DEVICE_ID");

Since the SDK hashes your device ID, it is much easier and cleaner to grab this number directly through the logs rather than bothering to try to grab the Android device ID, and doing some manual hashing to try to get this same number.




回答3:


In android < 4

How to find serial number of Android device?

In the new Android 4.0+ you can find the id number in the Settings --> Developer Options



来源:https://stackoverflow.com/questions/9681400/android-get-device-id-for-admob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!