Difference between DEVICE_ID_EMULATOR and TEST_EMULATOR when testing Admob on mobile phone

做~自己de王妃 提交于 2020-01-21 05:45:28

问题


What is the difference between using TEST_EMULATOR and DEVICE_ID_EMULATOR? I want to test the admob ad system on my mobile phones, NOT on an emulator on the PC.

AdRequest ad = new AdRequest.Builder().
 .addTestDevice(com.google.ads.AdRequest.TEST_EMULATOR).
 .addTestDevice("YOUR_HASHED_DEVICE_ID").
 .build();

AdRequest ad = new AdRequest.Builder().
 .addTestDevice(com.google.ads.AdRequest.DEVICE_ID_EMULATOR).
 .addTestDevice("YOUR_HASHED_DEVICE_ID").
 .build();

回答1:


  1. The difference is that com.google.ads.AdRequest.TEST_EMULATOR refers to the old legacy admob and com.google.android.gms.ads.AdRequest.DEVICE_ID_EMULATOR is the new google play services version of admob. This has replaced the old legacy admob. Obviously you should now only use the new admob as the old one is deprecated.

  2. To test admob ads on a real device you need to get the mobile device id hash and put it here: .addTestDevice("YOUR_HASHED_DEVICE_ID"). Admob adds a log with the device id in the logcat that looks more or less like this:

05-20 20:27:20.888: I/Ads(32367): Use AdRequest.Builder.addTestDevice("BANANANAANANANANANANNANANANANANA") to get test ads on this device.

Just copy this as a parameter in the addTestDevice method.



来源:https://stackoverflow.com/questions/30355041/difference-between-device-id-emulator-and-test-emulator-when-testing-admob-on-mo

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