Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity has leaked IntentReceiver com.mopub.mobileads.MoPubView that was originally registered here. Are you missing a call to unregisterReceiver()?

I’m trying to execute Banner & Fullscreen ads at MoPub, but i’m getting these two errors.

Thank You.

Error 1 : Refresh disabled for ad unit (unit id here)

Error 2 : Activityname has leaked IntentReceiver com.mopub.mobileads.MoPubView$1@a72e13a that was originally registered here. Are you missing a call to unregisterReceiver()?

I’m executing it like this.

mInterstitial_recent = new MoPubInterstitial(MainActivity.this, getString(R.string.Recent_Matches_Interstitial));
mInterstitial_recent.load();
mInterstitial_recent.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {
    @Override
    public void onInterstitialLoaded(MoPubInterstitial interstitial) {
        if (mInterstitial_recent.isReady()) {
            mInterstitial_recent.show();
        }
    }

    @Override
    public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
        startActivity(new Intent(MainActivity.this, Recent_Matches.class));
    }

    @Override
    public void onInterstitialShown(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialClicked(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialDismissed(MoPubInterstitial interstitial) {
        startActivity(new Intent(MainActivity.this, Recent_Matches.class));
    }
});
like image 653
Pranav Fulkari Avatar asked Oct 16 '22 19:10

Pranav Fulkari


1 Answers

For Error 1, make sure Your Ad unit has a refresh rate added for it in the MoPub Server-side UI.

Navigate to Apps > YOUR_APP_NAME > YOUR_AD_UNIT > Edit ad unit

In the edit ad unit form, you will see a "Refresh interval" field that you can update and save.

For Error 2, make sure you are destroying MoPub ad views in OnDestroy() of the activity. Example code below -

@Override
protected void onDestroy() {

      if ( mMoPubView != null ){
              mMoPubView.destroy();
      }

      if ( mInterstitial != null ){
              mInterstitial.destroy();
      }
      super.onDestroy();
  }
like image 137
Arushi Pant Avatar answered Oct 29 '22 18:10

Arushi Pant