What is the value of an AdMob test device?

I saw that there is a specific test identifier for testing AdMob ads on Android devices. I know how to get test id from cat log.

What is the difference between testing ads on Android devices with the expression adRequest.addTestDevice("TEST_DEVICE_ID"); and without it? Because in both scenarios I can receive ads without any problems.

The code:

 AdRequest adRequest = new AdRequest(); adRequest.addTestDevice("TEST_DEVICE_ID"); 
+4
source share
3 answers

Through this, you download test ads to your device / emulator.

This is good, because many times you can use ads by mistake, and your account may be banned if this happens regularly or if Admobs decides that you do these taps intentionally in order to increase your income.

From the docs:

https://developers.google.com/admob/android/targeting#adrequest

Requesting test ads is recommended. When testing the application, you do not request invalid impressions. In addition, you can always count on an affordable test ad.

+4
source

"TEST_DEVICE_ID" is just the place for the unique identifier of your device.
It should be replaced with something like:

 adRequest.addTestDevice("3E4409D3BCF2XXXXX5D87F53CD4XXXXX"); 

To find the identifier of your device: run the application with adRequest.addTestDevice("TEST_DEVICE_ID"); in the code, this will output your device ID to the log. Find the logcat trace for the INFO message containing the text:

 adRequest.addTestDevice 
+5
source

Use this:

 new AdRequest.Builder() .addTestDevice(Device.getId(this)) .build(); 

Device class:

 public class Device { public static String getId(Context context) { String deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); try { MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); digest.update(deviceId.getBytes()); byte messageDigest[] = digest.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; hexString.append(h); } deviceId = hexString.toString(); } catch (NoSuchAlgorithmException e) { deviceId = ""; } finally { return deviceId.toUpperCase(); } } } 
0
source

Source: https://habr.com/ru/post/1500240/


All Articles