0

I am using admobs in my android app and would like to test it with selected users on forums , family and friends.

I would like to display the test ads on their devices to avoid issues with conditions.

The doc says:

adRequest.addTestDevice("TEST_DEVICE_ID");// Test Android Device

But as I plan to share to non-tech people, I am pretty sure they won't be able to get their devices ID.

Is there a way to force displaying test ads on any devices?

Thank a lot.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260

3 Answers3

1

You can use below line

adRequest.setTesting(true);

See I have used like this for testing purpose

AdRequest adRequest = new AdRequest();
adRequest.setTesting(true);
adView.loadAd(adRequest);
Nirali
  • 13,571
  • 6
  • 40
  • 53
0

I don't know if there is a way to display test ads on select devices, but you could insert a view that has the same dimensions as the ad (50 by 350 I think?) and make it clear that an ad should go there. If you really wanted to you could even make it an image view, take a screen shot of Google's test ad, and create an onClickListener that sends you to Google.com.

jcw
  • 5,132
  • 7
  • 45
  • 54
0

This one was the correct answer

https://stackoverflow.com/a/8665279/327402

Not official but at least, that works!

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);
}
adRequest.addTestDevice(obj.toString());
Community
  • 1
  • 1
Waza_Be
  • 39,407
  • 49
  • 186
  • 260