0

i dont get it InterstitialAd and i coudnt find any example.if you have a example, can you post it .i try banner is it works . but when i try InterstitialAd i get error.i want when i open app i wanna see ads .

Thanks!!

package com.example.reklam3;

import android.app.Activity;

import com.google.ads.*;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.InterstitialAd;

public class MainActivity extends Activity implements AdListener{

  private InterstitialAd interstitial;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Create the interstitial
    interstitial = new InterstitialAd(this,"ca-app-pub-90707885707358xx");

    // Create ad request
    AdRequest adRequest = new AdRequest();

    // Begin loading your interstitial
    interstitial.loadAd(adRequest);

    // Set Ad Listener to use the callbacks below
    interstitial.show();
  }

  @Override
  public void onReceiveAd(Ad ad) {
    Log.d("OK", "Received ad");
    if (ad == interstitial) {
      interstitial.show();
    }
  }

@Override
public void onDismissScreen(Ad arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onLeaveApplication(Ad arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onPresentScreen(Ad arg0) {
    // TODO Auto-generated method stub

}
}

if you have a sipmle examle can you post it .ty

user2741142
  • 11
  • 2
  • 6

1 Answers1

0

I just posted an answer about this question here:

https://stackoverflow.com/a/24150614/1287856

Basically, you need to:

  • Call adRequest.build() before // Begin loading your interstitial
Community
  • 1
  • 1
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101