0

I'm implementing interstitial banners on this Android app and wish them to appear when user finish()es the app through back button. It's already working fine when using solo AdMob interstitial by AdMob mediation, this way:

@Override
public void finish() {
    if (isBannerAllowed() && InterstitialBannerFactory.getInsterstitialSingleton().isReady()) {
        InterstitialBannerFactory.getInsterstitialSingleton().show();
    }
            finish();
}

It shows the AdMob banner and when user dismisses, it will finish the app the expected way.

BUT, when I include an InMobi interstital banner on mediation, it shows the banner but instantly finishes the app (strictly the remaining last activity of the app), without giving chance to user view the banner. It appears and suddenly finishes.

I know it happens because in some way that finish() on the end doesn't work fine with InMobi interstitial. I already tried to do something like this:

@Override
public void finish() {
    setAppFinishing(true);
    if (isBannerAllowed() && InterstitialBannerFactory.getInsterstitialSingleton().isReady()) {
        InterstitialBannerFactory.getInsterstitialSingleton().show();
    }
}

Note the setAppFinishing(true) at the begining and the removal of the finish() at the end.

It gets a little better, since it shows the InMobi interstitial. But prevents the user from exiting the app through back button.

Then I tried this on AdListerner's onDismissScreen() to complement above code:

@Override
public void onDismissScreen(Ad ad) {
    // prepares the next
    if (!isAppFinishing()) {
        InterstitialBannerFactory.loadAd();
    }
    else {
        finish();
    }
}

But it doesn't take effect, the behaviour is the same and app is not exiting.

Does anyone have a smarter solution?

BTW, i'm using latest versions of all libs involved.

Regards.

4

1 に答える 1

3

InMobi のインタースティシャルは同じアクティビティに表示されますが、AdMob のインタースティシャルは新しいアクティビティで開始するように見えます。

これを解決するには、アプリで戻るボタンをオーバーライドします。詳細については、「戻るボタンをオーバーライドしてホーム ボタンのように動作させる」を参照してください。

例 -

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        Log.d(this.getClass().getName(), "back button pressed");
        if (interstitial.isReady()){
            interstitial.show();
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

注: onCreate は新しいインタースティシャル オブジェクトを作成し、その上でロードを呼び出します。インタースティシャルが閉じられたときに最終的にアプリを終了するコード:

@Override
public void onDismissScreen(Ad ad) {
   finish();
}

-InMobi、SDK 開発者、Akshay 氏

于 2013-08-30T07:20:32.370 に答える