1

Before when I have to display ads I would put the xml part of adMob in a layout and in the Java part I used code like

AdView mAdview;
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdview = findViewById(R.id.adView_id);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); 
mAdview.loadAd(adRequest);

And it worked.

Now I am creating an app which display ads on its preference screen . I used the following method described in stackoverflow to display my ad

https://stackoverflow.com/a/5850299/10403812

https://stackoverflow.com/a/45341837/10403812

It is working fine and my ads are being displayed on the preference screen . But I just want to know

1 . Do we not need to initialize our ads here like MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); here

2 . The solution only uses the unit ID of the ad . So we do not need the admob app ID here

Is it ok to use admob without initialize and app ID .

0 Answers0