我创建了 Admob 视频奖励广告。我的 admob 帐户是旧的,我已在我的另一个应用程序中成功展示了一个插页式广告。但是,我刚刚在 admob 中添加了一个新应用程序并创建了一个 admob 视频。视频显示良好,带有 admob 提供的测试 ID。但是当我使用我的真实视频奖励 ID 时,广告加载失败。对于,查询我已经添加了测试设备ID。
有什么东西,我想念的吗?
这是我的代码,它很好地加载了测试广告 id,但不是真正的广告 id:
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
private RewardedVideoAd mRewardedVideoAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
waitingDialog = new SpotsDialog(MainActivity.this);
MobileAds.initialize(this, "my_App_ID");
// Use an activity context to get the rewarded video instance.
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
mRewardedVideoAd.loadAd("REAL_REAWARDED_VIDEO_ID",
new AdRequest.Builder().addTestDevice("MY_DEVICE_ID").build());
}
public void arabicSearchActivity (View view){
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}else {
Toast.makeText(this, "Slow Internet, Please Click Again", Toast.LENGTH_SHORT).show();
loadRewardedVideoAd();
}
}
@Override
protected void onStop() {
if (waitingDialog!=null&&waitingDialog.isShowing())
waitingDialog.dismiss();
super.onStop();
}
@Override
public void onResume() {
mRewardedVideoAd.resume(this);
super.onResume();
}
@Override
public void onPause() {
mRewardedVideoAd.pause(this);
super.onPause();
}
@Override
public void onDestroy() {
mRewardedVideoAd.destroy(this);
super.onDestroy();
}
@Override
public void onRewarded(RewardItem reward) {
Toast.makeText(this, "onRewarded! currency: " + reward.getType() + " amount: " +
reward.getAmount(), Toast.LENGTH_SHORT).show();
// Reward the user.
startActivity(new Intent(MainActivity.this, SearchArabic.class));
}
@Override
public void onRewardedVideoAdLeftApplication() {
Toast.makeText(this, "onRewardedVideoAdLeftApplication",
Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed() {
Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
loadRewardedVideoAd();
}
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
Toast.makeText(this, "Please Check Internet Connections", Toast.LENGTH_LONG).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();
}