Ad pops up multiple times

徘徊边缘 提交于 2019-12-24 12:17:03

问题


If the player shield gets below 0 the game ends and an ad should pop up once and stay till the next game is started but it pops up twice. I cant find my mistake.

if (hitDetected){
                player.reduceShieldStrength();
                if (player.getShieldStrength() < 0) {
                    gameEnded = true;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                        showBanner();
                        }
                    });
                }
            }

        if (player.getShieldStrength() > 0){
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    hideBanner();
                }
            });
        }

My showBanner Method:

private void showBanner() {
    adView.setVisibility(View.VISIBLE);
    adView.loadAd(new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
}

来源:https://stackoverflow.com/questions/35113505/ad-pops-up-multiple-times

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!