I used to display AdMob banner on my future apps, and I'd like to give a try to the interstitial ads.
I checked the AdMob SDK for implementation, and I copied their example source because it was exactly what I want (i.e. the interstitial shown when the activity launch).
I tried it on emulator and on my Galaxy, no ad has been displayed.
Here is the source code:
public class Asscreed extends Activity {
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_asscreed);
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-6046034785851961/xxxxxx");
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequest);
}
// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
The imports are OK and the Google Play Services library is of course imported.
I use this example: AdMob Android Guides - Interstitial Ad.
Could someone tell me what's wrong in my code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…