奖励视频广告无法加载

时间:2017-11-28 18:46:18

标签: android admob rewardedvideoad

每次运行代码时,都会调用onRewardedVideoAdFailedToLoad(int i)函数。我正在使用codelabs example。 对不起英语不好,谢谢你的帮助。 这是我的代码。我用了很多教程。 有什么我以错误的方式做到了吗?

或者我错过了一些步骤?

public class Rewardedvideo extends AppCompatActivity implements 
RewardedVideoAdListener {
RewardedVideoAd mAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rewardedvideo);
    MobileAds.initialize(getApplicationContext(), "ca-app-pub-
3940256099942544~3347511713");

    mAd=MobileAds.getRewardedVideoAdInstance(Rewardedvideo.this);
    mAd.setRewardedVideoAdListener(this);
    loadrewardedvideoAd();
}
public void loadrewardedvideoAd(){
    if(!mAd.isLoaded()){
        mAd.loadAd("ca-app-pub-3940256099942544/5224354917",new 
AdRequest.Builder().build());
    }
}
public void startvideo(){
    if(mAd.isLoaded()){
        mAd.show();
    }
    else {
        mAd.loadAd("ca-app-pub-3940256099942544/5224354917",new 
AdRequest.Builder().build());
        mAd.show();
    }
}
@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();
    startvideo();
}

@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 onResume() {
    mAd.resume(this);
    super.onResume();
}

@Override
public void onPause() {
    mAd.pause(this);
    super.onPause();
}

@Override
public void onDestroy() {
    mAd.destroy(this);
    super.onDestroy();
}
}

这是我的代码。我用了很多教程。 有什么我以错误的方式做到了吗?

或者我错过了一些步骤?

1 个答案:

答案 0 :(得分:0)

我认为这不是视频来源。 几次后再试一次