0

I am a noob in android studio. And I want to put an ad on multiple activities. Some say that it needs an admob fragment to make it possible. So can someone give me an example or source code for the banner admob fragment.

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
israejumbo
  • 11
  • 2

1 Answers1

0

Add this code and show InterstitialAd in your activity in onCreate

  InterstitialAd interAd = new InterstitialAd(this);
            interAd.setAdUnitId("Add your adMob key");
            requestNewInterstitial();

            interAd.setAdListener(new AdListener() {
                @Override
                public void onAdLoaded() {
                    displayInterstitial();
                }
            });


     public void displayInterstitial(){

    if (interAd.isLoaded()){
        interAd.show();

    };
}

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder()
            .build();
    interAd.loadAd(adRequest);

}
Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
  • Interstitials are not banners. And interstitials are never used with fragments as they appear fullscreen and not as part of a screen. You're not really answering the question. – Codo Sep 17 '15 at 06:05
  • sorry , ok i am sending banner code.. – Abhinav singh Sep 17 '15 at 06:19