Problem loading admob ads

1

I have problems implementing rewarded ads in my app. I'm using admob for the ads and I followed all the steps indicated here:

link link

But when launching the application it tells me that the ad failed to load. I am doing something wrong? Thanks.

MainActivity:

public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {

Button boton;

private RewardedVideoAd mRewardedVideoAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    boton = (Button)findViewById(R.id.boton);

    // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
    MobileAds.initialize(this, "ca-app-pub-7147850182235133~6727239853");

    // Use an activity context to get the rewarded video instance.
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
    mRewardedVideoAd.setRewardedVideoAdListener(this);

    loadRewardedVideoAd();
}

private void loadRewardedVideoAd() {
    mRewardedVideoAd.loadAd("ca-app-pub-7147850182235133/4302033289",
            new AdRequest.Builder().build());
}

@Override
public void onRewarded(RewardItem reward) {
    Toast.makeText(this, "onRewarded! currency: " + reward.getType() + "  amount: " +
            reward.getAmount(), Toast.LENGTH_SHORT).show();
    // Reward the user.
}

@Override
public void onRewardedVideoAdLeftApplication() {
    Toast.makeText(this, "onRewardedVideoAdLeftApplication",
            Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdClosed() {
    Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
    Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdLoaded() {
    Toast.makeText(this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdOpened() {
    Toast.makeText(this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoStarted() {
    Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoCompleted() {
    Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}

public void boton(View view){
    if (mRewardedVideoAd.isLoaded()) {
        mRewardedVideoAd.show();
    }
}

}

    
asked by Agustin Val 25.06.2018 в 01:11
source

0 answers