简体   繁体   中英

Is it allowed to hide/unhide an Admob ad with a timer?

Is it allowed to manually hide/unhide the same Admob Ad after a certain time and does the ad need to be displayed for a particular time to count as an impression?

What i do is create a random int and when the int is value 2 i display the ad for 15s and then i set the visibility to invisible.

My code:

int randomIndex;
Random random = new Random();

randomIndex = random.nextInt(5);
Log.d(TAG,"randomIndex: "+randomIndex);

        if (randomIndex == 2) {
            if (mFrameLayoutBigAd.getVisibility() == View.INVISIBLE) {
                mFrameLayoutBigAd.setVisibility(View.VISIBLE);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mFrameLayoutBigAd.setVisibility(View.INVISIBLE);
                    }
                }, 15000);
            }
        }else{
            mFrameLayoutBigAd.setVisibility(View.INVISIBLE);
}

EDIT

if the ad is set to be visible again i just load the old adrequest again, so i'm not making a new ad request.

Yes, you can hide and show an ad, but there is a risk that the user will accidentally click when the ad reappears, which can be identified as click-inducing, which violates the AdMob guidelines. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM