Activity re-loading with AdMob
I have the following issue, where I load an ad with AdMob on my home screen. While it is busy loading the user can navigate away to another activity. If the ad didn't finish loading before then, it automatically takes the user back to the home screen from it's current activity.
So how do I either block the user to navigate away while the ad is loading (though I don't really want to do that) OR how do I stop the ad from loading if the user navigates away?
Basically, how can I improve the user experience and not have them have to wait for the开发者_开发知识库 ad to finish loading, but still have the ad present at a later stage
Much appreciate any advice!
Difficult to say for sure without seeing your code, but here's how I resolved this issue:
My app had the following in my activity onCreate():
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
and in the layout .xml for that activity:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="AD_UNIT_ID"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
Issue resolved by commenting out the loadAd call in the onCreate():
AdView adView = (AdView)this.findViewById(R.id.adView);
// adView.loadAd(new AdRequest());
精彩评论