gpt4 book ai didi

android - Admob 奖励视频测试广告未加载

转载 作者:行者123 更新时间:2023-11-29 02:32:51 24 4
gpt4 key购买 nike

我已经在我的应用程序中实现了 Admob。我正在使用测试广告进行测试。 横幅Interstitial TestAds运行良好,但奖励视频广告失败并出现代码 3

我不知道,这是怎么回事。两者都运行良好,但激励视频广告未加载。

在 Gradle 中使用 compile 'com.google.android.gms:play-services-ads:11.8.0'

我的代码:

mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().addTestDevice(getResources().getString(R.string.MyTestDevice)).build());

最佳答案

我完全使用了您的代码并且工作正常。你可以看看:

public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener{
private RewardedVideoAd mRewardedVideoAd;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = findViewById(R.id.btn_ad);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
});
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}

@Override
public void onRewardedVideoAdLoaded() {

}

@Override
public void onRewardedVideoAdOpened() {

}

@Override
public void onRewardedVideoStarted() {

}

@Override
public void onRewardedVideoAdClosed() {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}

@Override
public void onRewarded(RewardItem rewardItem) {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}

@Override
public void onRewardedVideoAdLeftApplication() {

}

@Override
public void onRewardedVideoAdFailedToLoad(int i) {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}
}

关于android - Admob 奖励视频测试广告未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48662368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com