我正在開發一個android應用,並希望在用戶退出應用後按按鈕時顯示mopub插頁式全屏廣告。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 [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.myActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
雖然我得到這個錯誤,添加顯示(我已經在很多設備上測試過),它似乎在除了索尼以外的所有工作。
我該如何改進此代碼以在退出時顯示插頁式廣告?
謝謝!
我已經用我使用的解決方案回答了問題,但也許您的答案也可能有效。非常感謝你。 – ljmelgui