Correctly disable AdMob ads

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

    Make a class which is called Ads like this

        public static boolean Show(AdView mAdView){
    
            if(mAdView != null){
                AdRequest adRequest = new AdRequest.Builder().build();
                mAdView.loadAd(adRequest);
                return true;
            }
            return false;
            }
        public static void Remove(AdView mAdView,ViewGroup parent){
            root.removeView(mAdView);
            }
        public static void Remove(AdView mAdView,RelativeLayout mLayout){
            mLayout.removeView(mAdView);
            }
        public static void Remove(AdView mAdView, LinearLayout mLayout){
            mLayout.removeView(mAdView);
            }
          }
    

    Now import it in the class where you want to remove an AdView from use Ads.Remove(AdView, parent); to remove it. `Ads.Remove("the add view itself", the ViewGroup or layout where it is");

提交回复
热议问题