I hide admob adview by view.gone:
//adView.setClickable(false);
//adView.clearFocus();
//adView.setEnabled(false);
//adView.setFilterTouchesWhenObscured(true);
//adView.setFocusable(false);
//adView.setFocusableInTouchMode(false);
adView.setVisibility(View.GONE);
adView.startAnimation( animation );
This hides the ad, but the adview itself is still touchable, so if I touch the adview's space, it still opens the browser and redirects me to the ad, although the ad itself is not visible.
How to disable the touch event too? I've tried all lines above but none of them worked.
Any advice?
Setting
adView.setVisibility(View.GONE)
and removing the AdMob view from the view hierarchy will hide the ad and prevent user interaction in most cases.Don't forget to end the AdView lifecycle when the Activity displaying the ad is finished (destroyed). From the AdMob SDK Javadoc:
Make a call to
destroy()
in the Activity'sonDestroy()
callback:Try to use setOnTouchListener and Override onTouch like you want. Also you can use removeView():
and add it back when you need.
even this code doesn't destroy AdMob =((( I have it's Handler and WebView in memory holding my activity