我创建了一个带有激励视频广告的应用。当我点击按钮时,广告没有被加载。我已经尝试测试广告单元 ID 和我的 admob id,但都不起作用。每当我单击该按钮时,它都会显示“广告服务器没有填充。无法加载广告:3”我不知道该怎么做。
MobileAds.initialize(getApplicationContext(),"ca-app-pub-4786107620829013~6803627405");
mad = MobileAds.getRewardedVideoAdInstance(this);
mad.setRewardedVideoAdListener(this);
mad.loadAd("ca-app-pub-xxxxxxxxxxx", new AdRequest.Builder().build());
public void Clicked(View view) {
if (mad.isLoaded())
{
mad.show();
}
}
@Override
public void onRewardedVideoAdLoaded() {
Toast.makeText(this, "Video loaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdOpened() {
Toast.makeText(this, "Video Opened", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoStarted() {
Toast.makeText(this, "Video Started", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed() {
}
@Override
public void onRewarded(RewardItem rewardItem) {
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(this, "Fail", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoCompleted() {
Toast.makeText(this, "Complete Video", Toast.LENGTH_SHORT).show();
}