Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling test/production "Ad Unit ID" in admob android application

Tags:

android

admob

I'm making an application including admob ads with help of this google's official tutorial

However, it states "You should always use test ads when developing and testing your app--testing with live production ads is a violation of AdMob policy and could cause your account to be suspended".

So I now have a test and a production Ad Unit ID. Should I manually switch my code to production/test id during my application release process or is there an kind of automatic for this?

Thank you

like image 236
gadjou Avatar asked Oct 22 '25 08:10

gadjou


1 Answers

you can use the production Ad Unit ID for your testing. just include the test device and it'll automatically load the test ads.

private static final String TEST_DEVICE ="xxxx..."; //see Log cat for the value.

AdRequest adrequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice(TEST_DEVICE)
            .build();

if (adview !=null)
       adview.loadAd(adRequest);

see this post on how to get the TEST_DEVICE id How can I get device ID for Admob

like image 188
Angel Koh Avatar answered Oct 24 '25 23:10

Angel Koh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!