interstitial.setAdListener(new AdListener(){
public void onAdLoaded(){
display();
}
});
I tried with the debugger, the 1st line was run, but the second line was simply not run. This is how I initialize the ad in the onCreate method:
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("******************************");
AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);
and InterstitialAd interstitial;
outside of the method inside the class. The AdUnitId was deliberately blanked out.
Logcat:
05-17 20:10:49.802: E/GooglePlayServicesUtil(17509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-17 20:10:49.807: E/GooglePlayServicesUtil(17509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-17 20:10:51.597: I/GATE(17509): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
05-17 20:10:51.597: I/Ads(17509): Scheduling ad refresh 60000 milliseconds from now.
05-17 20:10:51.602: I/Ads(17509): Ad finished loading.
05-17 20:10:51.632: D/TilesManager(17509): Starting TG #0, 0x5b3446f0
05-17 20:10:51.632: D/TilesManager(17509): new EGLContext from framework: 593202c0
05-17 20:10:51.632: D/GLWebViewState(17509): Reinit shader
05-17 20:10:51.632: D/GLWebViewState(17509): Reinit transferQueue
05-17 20:10:56.262: D/AbsListView(17509): Get MotionRecognitionManager
05-17 20:11:31.987: I/Ads(17509): Ad is not visible. Not refreshing ad.
05-17 20:11:31.992: I/Ads(17509): Scheduling ad refresh 60000 milliseconds from now.
Use the following code to display the ad's listener on AdLoaded(). I used the same. It was worked for me.
Outside oncreate function use below code:
Do NOT call display() from #onAdLoaded. This will results is a very poor UX. Instead call display from a natural break point in your application (if an ad has been loaded).
Also these lines in your logs suggest that you also have banner ads.
If that is not the case then you have misconfigured your adUnit because you are getting auto refresh which does not happen for an interstitial. You need to explicitly load an interstitial each time.
Are you missing @override before onAdLoaded() method
Hope you have added following in AndroidManifest.xml
Internet permission
AdActivity
Google Play service lib under application tag
And added code as