gpt4 book ai didi

Android:当用户退出应用程序点击后退按钮时显示 mopub 插页式广告

转载 作者:搜寻专家 更新时间:2023-11-01 08:03:33 24 4
gpt4 key购买 nike

我正在开发一个 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()?

虽然我收到此错误,但显示了添加(我已经在许多设备上对其进行了测试)并且它似乎在除索尼之外的所有设备上都运行良好。

我如何改进此代码以在退出时显示插页式广告?

谢谢!!

最佳答案

您在销毁时加载插页式广告。当您的 Activity 在您泄漏的间隙负载后被破坏时。在 ondestroy 中调用 interstitial.destroy()。

您可能想要做的是处理 onbackpressed。在创建时加载插页式广告,在 backpressed 时显示它并在销毁时销毁它。

关于Android:当用户退出应用程序点击后退按钮时显示 mopub 插页式广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17567398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com