@Override protected void onWindowVisibilityChanged(int visibility) { if (mAdView == null) return; if (visibility == VISIBLE) { Log.d("MoPub", "Ad Unit (" + mAdView.getAdUnitId() + ") going visible: enabling refresh"); mIsInForeground = true; mAdView.setAutorefreshEnabled(true); } else { Log.d("MoPub", "Ad Unit (" + mAdView.getAdUnitId() + ") going invisible: disabling refresh"); mIsInForeground = false; mAdView.setAutorefreshEnabled(false); } }
/* * Stops refreshing ads. */ protected void cleanup() { setAutorefreshEnabled(false); }
public void setAutorefreshEnabled(boolean enabled) { if (mAdView != null) mAdView.setAutorefreshEnabled(enabled); }