Correctly disable AdMob ads

前端 未结 9 1649
感情败类
感情败类 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:54

    In your layout file (eg, main.xml) :

    
    
        
    
    
    

    Then in your code (eg, inside a "if" block)

    (LinearLayout) adscontainer = (LinearLayout) findViewById(R.id.adsContainer);
    
    View admobAds = (View) findViewById(R.id.admobAds);
    
    adscontainer.removeView(admobAds);
    

    This will "permanently" (for the lifecycle of the app) remove the ads from the layou, which means that there will not be any ads requested.

提交回复
热议问题