I have 7 Activities in my application. I wants to display admob in every activity
Whether i have to create each AdView in every activity?>
In my app I have a cache of 0..12 ads at any given time. I'm reusing them accross different Fragments in an endless ViewPager. The caching class is in charge of loading the providing the ads to the Fragments.
The trick is to:
Call the AdView's onDestory only when you're sure you're done with that AdView instance for good. This means that the Fragments themselves are not in charge of this.
Passing the AdView's themselves between the Fragments, we need to remember to detach each AdView from its hierarchy:
(only on the UI thread of course):
public void detachFromHirerchy()
{
View adView = getAdView();
if ( adView != null )
{
ViewGroup parent = (ViewGroup) adView.getParent();
if (parent != null)
{
parent.removeView( adView );
}
}
}