Correctly disable AdMob ads

前端 未结 9 1605
感情败类
感情败类 2020-12-02 05:13

I am integrating AdMob into my app and I wonder how to disable Ads correctly. I want to give the user the ability to disable them. I don\'t want to get any problems with AdM

相关标签:
9条回答
  • 2020-12-02 05:56

    setVisibility(VIEW.GONE); will remove the adview from the layout.

    There might be away to fully remove it from the layout, but I've never had to do that.

    0 讨论(0)
  • 2020-12-02 06:06

    Just setting the view's visibility to GONE is enough.

    If you read the Logcat output, it prints "I/Ads: Ad is not visible. Not refreshing ad.".

    0 讨论(0)
  • 2020-12-02 06:07

    Give it all you've got, just to be on the safe side:

    if (mAdView != null) {
        mAdView.setEnabled(false);
        mAdView.setVisibility(View.GONE);
    
        ViewGroup parent = (ViewGroup) mAdView.getParent();
        if (parent != null) parent.removeView(mAdView);
    
        mAdView.removeAllViews();
        mAdView.destroy();
    }
    
    0 讨论(0)
提交回复
热议问题