title: How to automatically close reward ad after rewarded [Android-Studio]
body: <p>So i'm trying to have it automatically close the ad after it rewards the user here is what I got so far.</p>
  
  <p>Keep in mind i'm new to android studio and java as a whole. If they are spaced they are in different methods. </p>
  
  <pre><code>private RewardedVideoAd mAd;
  
  AdView adView;
  void init_admob(){
      adView = (AdView) findViewById(R.id.adView);
      AdRequest adRequest = new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();
      adView.loadAd(adRequest);
      mAd = MobileAds.getRewardedVideoAdInstance(this);
      mAd.setRewardedVideoAdListener(this);
      loadRewardedVideoAd();
  }
  
  
  public void onRewarded(RewardItem reward) {
      Toast.makeText(this, reward.getAmount()+ " " +getString(R.string.points_received), Toast.LENGTH_SHORT).show();
      award(reward.getAmount(),getString(R.string.admob_credit));
      exitAd();
  }
  
  
  public void exitAd() {
      //dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); Tried But didn't work (No Errors Just didn't work)
      //dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK)); Tried but didn't work (No Errors Just didn't work)
      try {
          LinearLayout linLay = (LinearLayout) findViewById(R.id.adView);
          linLay.removeView(adView);
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Error For linLay</p>
  
  <pre><code>java.lang.ClassCastException: com.google.android.gms.ads.AdView cannot be cast to android.widget.LinearLayout
  </code></pre>
  
  <p>So I don't really know what else to try or how to close the AdView after the ad has rewarded any help is apperciated!</p>