问题
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:
The difference is that
com.google.ads.AdRequest.TEST_EMULATOR
refers to the old legacy admob andcom.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.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