我正在开发一个 android 应用程序,并希望在用户按下返回按钮退出应用程序时显示一个 mopub 插页式全屏广告。
我已经尝试过创建插页式广告并在 onDestroy 方法中显示它。像这样的东西:
@Override
public void onDestroy(){
this.interstitial = new MoPubInterstitial(this, MY_INTERSTITIAL_AD_UNIT_ID_HERE);
this.interstitial.setInterstitialAdListener(this);
this.interstitial.load();
super.onDestroy();
}
// InterstitialAdListener method
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
if (interstitial.isReady()) {
mInterstitial.show();
} else {
// Other code
}
}
但是,我不会在任何地方销毁插页式广告 (mInterstitial.destroy();),因为我不知道在哪里可以这样做,因此我收到此错误:
Activity com.myActivity has leaked IntentReceiver com.mopub.mobileads.MoPubView$1@41baffc0 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.myActivity has leaked IntentReceiver com.mopub.mobileads.MoPubView$1@41baffc0 that was originally registered here. Are you missing a call to unregisterReceiver()?
虽然我收到了这个错误,但显示了添加(我已经在许多设备上测试过它),它似乎在除索尼之外的所有设备中都运行良好。
如何改进此代码以在退出时显示插页式广告?
谢谢!!