I am trying to show an Interstitial ad from AdMob in my app but it really doesn't work. In fact, I can see this message in Logcat :
I/Ads﹕ Ad opening.
And then, my app is just freezing. Here is the code I have until now. Note that I am trying to show this Interstitial ad from a fragment.
In the method "onCreateView" of my fragment :
mInterstitialAd = new InterstitialAd(myContext);
mInterstitialAd.setAdUnitId(myContext.getString(R.string.interstitial_ad_unit_id));
requestNewInterstitial();
... and then, still in the same method :
send_love.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//new AttemptPostLove(user_id).execute();
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
});
And finally, the method "requestNewInterstitial();" from the Google Documentation :
private void requestNewInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
}
EDIT: I've just noticed this "warning" in my Logcat :
W/Ads﹕ It is not recommended to show an interstitial before onAdLoaded completes.
Even if I don't fire the click event which should show the interstitial.
Can you help me?
Thanks!
IT's not direct resolution, but should help with typical ANR's problems:
ANR WatchDog
Setup, run it and it will crash application with elegant stacktrace in logcat, describing place that causes problem. I bet that there is some long running action in main thread...