title: Unable to show interstitial ads with admob in andengine
body: <p>I have been trying to show interstitials in my andengine developed game but unable to. I have successfully integrated banner ads though. I prefer using coding for layout. Below are my GameActivity.java and the Gamescene.java classes, please help in understanding where is the root error?</p>
  
  <pre><code>public class GameActivity extends BaseGameActivity
  {
      private SmoothCamera camera;
      public Music music;`
  
      public static int flag=0;
  
  
      @Override
      public Engine onCreateEngine(EngineOptions pEngineOptions) 
      {
          return new LimitedFPSEngine(pEngineOptions, 60);
      }
  
      public EngineOptions onCreateEngineOptions()
      {
          camera = new SmoothCamera(0, 0, 720, 1280,5000000,5000000,1);
          EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), this.camera);
          engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);
          engineOptions.getRenderOptions().getConfigChooserOptions().setRequestedMultiSampling(true);
          engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
          engineOptions.getTouchOptions().setNeedsMultiTouch(true);
          return engineOptions;
      }
  
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) 
      {  
          if (keyCode == KeyEvent.KEYCODE_BACK)
          {
              SceneManager.getInstance().getCurrentScene().onBackKeyPressed();
          }
          return false; 
      }
  
      public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws IOException
      {
          ResourcesManager.prepareManager(mEngine, this, camera, getVertexBufferObjectManager());
          pOnCreateResourcesCallback.onCreateResourcesFinished();
  
  
          try
          {
              music = MusicFactory.createMusicFromAsset(mEngine.getMusicManager(), this,"music/music.ogg");
          }
          catch (IOException e)
          {
              e.printStackTrace();
          }
  
      }
  
      AdView adView ;@Override
      @SuppressLint("NewApi")
      protected void onSetContentView() {
  
  
          final FrameLayout frameLayout = new FrameLayout(this);
          final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(
                  FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, Gravity.FILL);
          final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
                  FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER | Gravity.TOP);
  
          adView = new AdView(this);
          adView.setAdUnitId("admobid");
          //adView.setAdUnitId("admobid");
          adView.setAdSize(AdSize.);
  
          adView.setVisibility(AdView.VISIBLE);
          adView.refreshDrawableState();
  
          AdRequest adRequest = new AdRequest.Builder().build();
          adView.loadAd(adRequest);
  
          if (android.os.Build.VERSION.SDK_INT &gt; android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
              adView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
          }
  
  
          this.mRenderSurfaceView = new RenderSurfaceView(this);
          mRenderSurfaceView.setRenderer(mEngine, this);
  
  
  
          final FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(
                  android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
          surfaceViewLayoutParams.gravity = Gravity.CENTER;
  
          frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
  
          adView.setAdListener(new AdListener() {
              public void onAdLoaded(){
  
                  if(flag==0)
                  {flag=1;
                  frameLayout.addView(adView, adViewLayoutParams);
  
                  }
              }
          });
  
  
          this.setContentView(frameLayout, frameLayoutLayoutParams);
  
      }
  
      public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException
      {
          SceneManager.getInstance().createSplashScene(pOnCreateSceneCallback);
      }
  
      public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws IOException
      {
          mEngine.registerUpdateHandler(new TimerHandler(2f, new ITimerCallback() 
          {
              public void onTimePassed(final TimerHandler pTimerHandler) 
              {
                  mEngine.unregisterUpdateHandler(pTimerHandler);
                  SceneManager.getInstance().createMenuScene();
  
              }
          }));
          pOnPopulateSceneCallback.onPopulateSceneFinished();
      }
      @Override
      protected void onPause() {
          SceneManager.getInstance().gameScene.onBackKeyPressed();
          super.onPause();
      }
      @Override
      protected void onDestroy()
      {
          super.onDestroy();
          System.exit(0); 
      }
  }
  </code></pre>
  
  <p>Gameover method where i am trying to put interstitial</p>
  
  <pre><code>private void gameover()
  {this.gameovercheck = 1;
  this.setIgnoreUpdate(true);
  Sprite gameover = new Sprite(camera.getCenterX(), camera.getCenterY(), resourcesManager.gameover, vbom);
  this.attachChild(gameover);
  rocket.setCurrentTileIndex(2);
  
  
        activity.runOnUiThread(new Runnable(){
  
          @Override
          public void run() {
              // TODO Auto-generated method stub
  
              InterstitialAd interstitial = new InterstitialAd(activity);
              interstitial.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
  
              AdRequest adRequest = new AdRequest.Builder().build();
  
  
              interstitial.loadAd(adRequest);
  
                  interstitial.show();
  
  
  
          }
  
      });
  soundOnBtn1 = new Sprite(camera.getCenterX(),camera.getCenterY()-200, resourcesManager.retry, vbom)
  {
  
      public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float X, float Y)
      {if(pSceneTouchEvent.isActionDown())
  
          SceneManager.getInstance().loadGameScene1(engine);
      gameovercheck=0;
      editor.commit();
      editor.commit();
      return true;
      };
  };
  this.attachChild(soundOnBtn1);
  this.registerTouchArea(soundOnBtn1);
  </code></pre>